diff options
author | Ludovic Rousseau <ludovic.rousseau@free.fr> | 2019-11-01 16:04:02 +0100 |
---|---|---|
committer | Ludovic Rousseau <ludovic.rousseau@free.fr> | 2019-11-23 18:20:50 +0100 |
commit | 1bb774ca7e5cb100e1fb7ac287e561b2155da70e (patch) | |
tree | 70874247dd57905fae7f0254e33347cd4d92c672 | |
parent | 4bf9c343598900188a48e58408aa7e340f7caf87 (diff) | |
download | libusb-1bb774ca7e5cb100e1fb7ac287e561b2155da70e.tar.gz |
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>
-rw-r--r-- | libusb/os/linux_usbfs.c | 4 | ||||
-rw-r--r-- | libusb/version_nano.h | 2 |
2 files changed, 5 insertions, 1 deletions
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 |