From 6edd96ab818fab9a35efa385b489b9a56ca91dbc Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Fri, 30 May 2014 12:25:18 +0200 Subject: libusb_submit_transfer: Don't reference the device on submission failure If submission fails libusb_ref_device will never get balanced by an unref on completion, since there will be no completion. Signed-off-by: Hans de Goede --- libusb/io.c | 6 +++--- libusb/version_nano.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/libusb/io.c b/libusb/io.c index 5c51d73..b9ca767 100644 --- a/libusb/io.c +++ b/libusb/io.c @@ -1456,10 +1456,10 @@ int API_EXPORTED libusb_submit_transfer(struct libusb_transfer *transfer) if (r != LIBUSB_SUCCESS) { list_del(&itransfer->list); arm_timerfd_for_next_timeout(ctx); + } else { + /* keep a reference to this device */ + libusb_ref_device(transfer->dev_handle->dev); } - - /* keep a reference to this device */ - libusb_ref_device(transfer->dev_handle->dev); out: updated_fds = (itransfer->flags & USBI_TRANSFER_UPDATED_FDS); usbi_mutex_unlock(&itransfer->lock); diff --git a/libusb/version_nano.h b/libusb/version_nano.h index 96ccb69..0d37865 100644 --- a/libusb/version_nano.h +++ b/libusb/version_nano.h @@ -1 +1 @@ -#define LIBUSB_NANO 10899 +#define LIBUSB_NANO 10900 -- cgit v1.2.3