comedi_open has file descriptor leak
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
This commit is contained in:
parent
50ad010b31
commit
2b8c2f8087
1 changed files with 7 additions and 1 deletions
|
@ -77,8 +77,14 @@ comedi_t* _comedi_open(const char *fn)
|
|||
|
||||
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;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue