Linux backend: fix ressource leak
authorLudovic Rousseau <ludovic.rousseau@free.fr>
Fri, 1 Nov 2019 15:04:02 +0000 (16:04 +0100)
committerLudovic Rousseau <ludovic.rousseau@free.fr>
Sat, 23 Nov 2019 17:20:50 +0000 (18:20 +0100)
Issue detected by Coverity:
22. leaked_handle: Handle variable fd going out of scope leaks the handle.

Signed-off-by: Ludovic Rousseau <ludovic.rousseau@free.fr>
libusb/os/linux_usbfs.c
libusb/version_nano.h

index 6f77e34..2bff8f6 100644 (file)
@@ -1049,7 +1049,11 @@ static int initialize_device(struct libusb_device *dev, uint8_t busnum,
        }
 
        if (sysfs_dir && sysfs_can_relate_devices)
+       {
+               if (fd != wrapped_fd)
+                       close(fd);
                return LIBUSB_SUCCESS;
+       }
 
        /* cache active config */
        if (wrapped_fd < 0)
index 7effa17..aebe182 100644 (file)
@@ -1 +1 @@
-#define LIBUSB_NANO 11410
+#define LIBUSB_NANO 11411