summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans de Goede <hdegoede@redhat.com>2014-05-30 12:25:18 +0200
committerHans de Goede <hdegoede@redhat.com>2014-05-30 12:37:37 +0200
commit6edd96ab818fab9a35efa385b489b9a56ca91dbc (patch)
treecd9b690de03ccd9ca34f25968dd647b2dd298034
parent4f347f01fa2745b7d00e6e336726c9a329bd6fbb (diff)
downloadlibusb-6edd96ab818fab9a35efa385b489b9a56ca91dbc.tar.gz
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 <hdegoede@redhat.com>
-rw-r--r--libusb/io.c6
-rw-r--r--libusb/version_nano.h2
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