comedi_open has file descriptor leak
authorAnders Blomdell <anders.blomdell@control.lth.se>
Wed, 22 Aug 2012 07:21:56 +0000 (08:21 +0100)
committerIan Abbott <abbotti@mev.co.uk>
Wed, 22 Aug 2012 08:54:19 +0000 (09:54 +0100)
commit2b8c2f8087d69be00c33a20d33d80106efa7f8a6
treeaff070ef6d110067682d50c3c926e32b5beea5ad
parent50ad010b31758b8868fe92e287606e8d8df3efbc
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
lib/comedi.c