libusbx/0004-Linux-backend-fix-ressource-leak.patch

33 lines
896 B
Diff
Raw Normal View History

From df7cb74443b31311bfc36977f1080aadbcac098d Mon Sep 17 00:00:00 2001
From: Ludovic Rousseau <ludovic.rousseau@free.fr>
Date: Fri, 1 Nov 2019 16:04:02 +0100
Subject: [PATCH 4/8] 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 <ludovic.rousseau@free.fr>
---
libusb/os/linux_usbfs.c | 4 ++++
1 file changed, 4 insertions(+)
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)
--
2.27.0.windows.1