From 3dbf0a9c5e772ffc8bbab499bcc0a81f5ccd96e3 Mon Sep 17 00:00:00 2001 From: Chris Dickens Date: Thu, 17 Sep 2015 22:27:21 -0700 Subject: [PATCH] linux_usbfs: Avoid file descriptor leak in error case Signed-off-by: Chris Dickens --- libusb/os/linux_usbfs.c | 6 +++++- libusb/version_nano.h | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/libusb/os/linux_usbfs.c b/libusb/os/linux_usbfs.c index a9ca506d..1bfcdd0b 100644 --- a/libusb/os/linux_usbfs.c +++ b/libusb/os/linux_usbfs.c @@ -1320,7 +1320,11 @@ static int op_open(struct libusb_device_handle *handle) hpriv->caps |= USBFS_CAP_BULK_CONTINUATION; } - return usbi_add_pollfd(HANDLE_CTX(handle), hpriv->fd, POLLOUT); + r = usbi_add_pollfd(HANDLE_CTX(handle), hpriv->fd, POLLOUT); + if (r < 0) + close(hpriv->fd); + + return r; } static void op_close(struct libusb_device_handle *dev_handle) diff --git a/libusb/version_nano.h b/libusb/version_nano.h index 112b99fc..031f02ef 100644 --- a/libusb/version_nano.h +++ b/libusb/version_nano.h @@ -1 +1 @@ -#define LIBUSB_NANO 11008 +#define LIBUSB_NANO 11009