summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans de Goede <hdegoede@redhat.com>2016-06-06 17:42:12 +0200
committerNathan Hjelm <hjelmn@me.com>2016-08-17 12:52:40 -0600
commitefcfe05a2a572b67a5fbacdc855ac678b2ce8380 (patch)
tree515a40260eb872c34592cf38a9c4565b5618b9c1
parentd5a1418d9fbab126ded971d34eb8e27cfaa58b3d (diff)
downloadlibusb-efcfe05a2a572b67a5fbacdc855ac678b2ce8380.tar.gz
core: Fix do_close locking
Put the lock / unlock calls around the part of the code which actually checks the flags which the lock protect. Signed-off-by: Hans de Goede <hdegoede@redhat.com>
-rw-r--r--libusb/core.c4
-rw-r--r--libusb/version_nano.h2
2 files changed, 3 insertions, 3 deletions
diff --git a/libusb/core.c b/libusb/core.c
index d1e93c8..99aab7b 100644
--- a/libusb/core.c
+++ b/libusb/core.c
@@ -1351,6 +1351,7 @@ static void do_close(struct libusb_context *ctx,
if (transfer->dev_handle != dev_handle)
continue;
+ usbi_mutex_lock(&itransfer->lock);
if (!(itransfer->state_flags & USBI_TRANSFER_DEVICE_DISAPPEARED)) {
usbi_err(ctx, "Device handle closed while transfer was still being processed, but the device is still connected as far as we know");
@@ -1359,15 +1360,14 @@ static void do_close(struct libusb_context *ctx,
else
usbi_err(ctx, "A cancellation hasn't even been scheduled on the transfer for which the device is closing");
}
+ usbi_mutex_unlock(&itransfer->lock);
/* remove from the list of in-flight transfers and make sure
* we don't accidentally use the device handle in the future
* (or that such accesses will be easily caught and identified as a crash)
*/
- usbi_mutex_lock(&itransfer->lock);
list_del(&itransfer->list);
transfer->dev_handle = NULL;
- usbi_mutex_unlock(&itransfer->lock);
/* it is up to the user to free up the actual transfer struct. this is
* just making sure that we don't attempt to process the transfer after
diff --git a/libusb/version_nano.h b/libusb/version_nano.h
index 9fb8855..6995b33 100644
--- a/libusb/version_nano.h
+++ b/libusb/version_nano.h
@@ -1 +1 @@
-#define LIBUSB_NANO 11134
+#define LIBUSB_NANO 11135