From 1bb774ca7e5cb100e1fb7ac287e561b2155da70e Mon Sep 17 00:00:00 2001 From: Ludovic Rousseau Date: Fri, 1 Nov 2019 16:04:02 +0100 Subject: Linux backend: fix ressource leak Issue detected by Coverity: 22. leaked_handle: Handle variable fd going out of scope leaks the handle. Signed-off-by: Ludovic Rousseau --- libusb/os/linux_usbfs.c | 4 ++++ libusb/version_nano.h | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/libusb/os/linux_usbfs.c b/libusb/os/linux_usbfs.c index 6f77e34..2bff8f6 100644 --- a/libusb/os/linux_usbfs.c +++ b/libusb/os/linux_usbfs.c @@ -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) diff --git a/libusb/version_nano.h b/libusb/version_nano.h index 7effa17..aebe182 100644 --- a/libusb/version_nano.h +++ b/libusb/version_nano.h @@ -1 +1 @@ -#define LIBUSB_NANO 11410 +#define LIBUSB_NANO 11411 -- cgit v1.2.1