aboutsummaryrefslogtreecommitdiffstats
path: root/libusb/sync.c
diff options
context:
space:
mode:
authorHans de Goede <hdegoede@redhat.com>2013-06-20 12:41:00 +0200
committerHans de Goede <hdegoede@redhat.com>2013-06-20 12:47:35 +0200
commitcb96ec5b4728a2d1cfc9bdf2c32e9e8c98ed074e (patch)
treebee1ed323e6d810829bf8106c2bc499982980219 /libusb/sync.c
parent2e5bc1013423812bb9397fce16b7646eb063a148 (diff)
downloadandroid_external_libusbx-cb96ec5b4728a2d1cfc9bdf2c32e9e8c98ed074e.tar.gz
android_external_libusbx-cb96ec5b4728a2d1cfc9bdf2c32e9e8c98ed074e.tar.bz2
android_external_libusbx-cb96ec5b4728a2d1cfc9bdf2c32e9e8c98ed074e.zip
Revert "Core: Don't wait for completion if cancel_transfer failed"
This reverts commit 2f5023c41d3176e56bf0abc521b7c5f8b1ac4664. 2f5023c4 was an attempt to fix: https://github.com/libusbx/libusbx/issues/76 As seen in: http://libusbx.1081486.n5.nabble.com/Libusbx-devel-libusb-interrupt-transfer-does-not-return-in-case-of-error-td626.html [372849.680990] [0000275b] libusbx: error [reap_for_handle] reap failed error -1 errno=14 [372849.681752] [0000275b] libusbx: error [handle_events] backend handle_events failed with error -1 [372850.680466] [0000275b] libusbx: warning [handle_timeout] async cancel failed -5 errno=22 The problem begins with reap_for_handle failing with errno == 14, which is EFAULT. So the real problem is the application passing in an invalid (or too short) buffer, and thus is an application bug. The fix masks this problem, but causes the problem of calling libusb_transfer_free() on a non finished transfer, so it is no good. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Conflicts: AUTHORS libusb/version_nano.h
Diffstat (limited to 'libusb/sync.c')
-rw-r--r--libusb/sync.c18
1 files changed, 8 insertions, 10 deletions
diff --git a/libusb/sync.c b/libusb/sync.c
index 55d4376..e115099 100644
--- a/libusb/sync.c
+++ b/libusb/sync.c
@@ -106,11 +106,10 @@ int API_EXPORTED libusb_control_transfer(libusb_device_handle *dev_handle,
if (r < 0) {
if (r == LIBUSB_ERROR_INTERRUPTED)
continue;
- if (libusb_cancel_transfer(transfer) == LIBUSB_SUCCESS) {
- while (!completed)
- if (libusb_handle_events_completed(HANDLE_CTX(dev_handle), &completed) < 0)
- break;
- }
+ libusb_cancel_transfer(transfer);
+ while (!completed)
+ if (libusb_handle_events_completed(HANDLE_CTX(dev_handle), &completed) < 0)
+ break;
libusb_free_transfer(transfer);
return r;
}
@@ -184,11 +183,10 @@ static int do_sync_bulk_transfer(struct libusb_device_handle *dev_handle,
if (r < 0) {
if (r == LIBUSB_ERROR_INTERRUPTED)
continue;
- if (libusb_cancel_transfer(transfer) == LIBUSB_SUCCESS) {
- while (!completed)
- if (libusb_handle_events_completed(HANDLE_CTX(dev_handle), &completed) < 0)
- break;
- }
+ libusb_cancel_transfer(transfer);
+ while (!completed)
+ if (libusb_handle_events_completed(HANDLE_CTX(dev_handle), &completed) < 0)
+ break;
libusb_free_transfer(transfer);
return r;
}