If something fails after a succesful open, cleanup fails to close the file.
The code
cleanup:
if(it)
free(it);
needs to be replaced with something like:
cleanup:
if (it) {
if (it->fd >= 0) {
close(it->fd);
}
free(it);
Regards
Anders Blomdell
return it;
cleanup:
- if(it)
+ if(it) {
+ /* As long as get_subdevices is the last action above,
+ it->subdevices should not need any cleanup, since
+ get_subdevices should have done the cleanup already */
+ if (it->fd >= 0)
+ close(it->fd);
free(it);
+ }
return NULL;
}