Blame SOURCES/0003-Linux-backend-fix-ressource-leak.patch

15070a
From 686536a2862f0d69e0075316ef54c1f927d134a3 Mon Sep 17 00:00:00 2001
15070a
From: Ludovic Rousseau <ludovic.rousseau@free.fr>
15070a
Date: Fri, 1 Nov 2019 16:04:02 +0100
15070a
Subject: [PATCH 03/10] Linux backend: fix ressource leak
15070a
15070a
Issue detected by Coverity:
15070a
22. leaked_handle: Handle variable fd going out of scope leaks the handle.
15070a
15070a
Signed-off-by: Ludovic Rousseau <ludovic.rousseau@free.fr>
15070a
(cherry picked from commit 1bb774ca7e5cb100e1fb7ac287e561b2155da70e)
15070a
---
15070a
 libusb/os/linux_usbfs.c | 4 ++++
15070a
 libusb/version_nano.h   | 2 +-
15070a
 2 files changed, 5 insertions(+), 1 deletion(-)
15070a
15070a
diff --git a/libusb/os/linux_usbfs.c b/libusb/os/linux_usbfs.c
15070a
index 63fe592..dace935 100644
15070a
--- a/libusb/os/linux_usbfs.c
15070a
+++ b/libusb/os/linux_usbfs.c
15070a
@@ -1049,7 +1049,11 @@ static int initialize_device(struct libusb_device *dev, uint8_t busnum,
15070a
 	}
15070a
 
15070a
 	if (sysfs_dir && sysfs_can_relate_devices)
15070a
+	{
15070a
+		if (fd != wrapped_fd)
15070a
+			close(fd);
15070a
 		return LIBUSB_SUCCESS;
15070a
+	}
15070a
 
15070a
 	/* cache active config */
15070a
 	if (wrapped_fd < 0)
15070a
diff --git a/libusb/version_nano.h b/libusb/version_nano.h
15070a
index a41e19e..aebe182 100644
15070a
--- a/libusb/version_nano.h
15070a
+++ b/libusb/version_nano.h
15070a
@@ -1 +1 @@
15070a
-#define LIBUSB_NANO 11404
15070a
+#define LIBUSB_NANO 11411
15070a
-- 
15070a
2.26.1
15070a