summaryrefslogtreecommitdiff
path: root/libusb/os/linux_usbfs.c
diff options
context:
space:
mode:
authorChris Dickens <christopher.a.dickens@gmail.com>2015-09-17 22:27:21 -0700
committerChris Dickens <christopher.a.dickens@gmail.com>2015-09-20 14:48:54 -0700
commit3dbf0a9c5e772ffc8bbab499bcc0a81f5ccd96e3 (patch)
tree1b6da0dc849bceaf625a4829298d06acbf925cec /libusb/os/linux_usbfs.c
parent377f513da146b4e1227689cae613a261b8fbd74c (diff)
downloadlibusb-3dbf0a9c5e772ffc8bbab499bcc0a81f5ccd96e3.tar.gz
linux_usbfs: Avoid file descriptor leak in error case
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
Diffstat (limited to 'libusb/os/linux_usbfs.c')
-rw-r--r--libusb/os/linux_usbfs.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/libusb/os/linux_usbfs.c b/libusb/os/linux_usbfs.c
index a9ca506..1bfcdd0 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)