comedi_open has file descriptor leak
[comedilib.git] / lib / comedi.c
index 5877e6a2548391215c0a8008f1b34c511fabd82a..0d2086fedeac57c5be5eff53d6a8e361dc65f3c2 100644 (file)
@@ -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;
 }