From c473ed5452f01b9ca4e38e703071c446142ca1f4 Mon Sep 17 00:00:00 2001 From: Ludovic Rousseau Date: Dec 09 2020 20:45:00 +0000 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 (cherry picked from commit 1bb774ca7e5cb100e1fb7ac287e561b2155da70e) patch_name: 0003-Linux-backend-fix-ressource-leak.patch present_in_specfile: true location_in_specfile: 3 squash_commits: true --- diff --git a/libusb/os/linux_usbfs.c b/libusb/os/linux_usbfs.c index 63fe592..dace935 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 a41e19e..aebe182 100644 --- a/libusb/version_nano.h +++ b/libusb/version_nano.h @@ -1 +1 @@ -#define LIBUSB_NANO 11404 +#define LIBUSB_NANO 11411