diff options
author | Chris Dickens <christopher.a.dickens@gmail.com> | 2015-08-02 23:19:57 -0700 |
---|---|---|
committer | Chris Dickens <christopher.a.dickens@gmail.com> | 2015-08-04 22:52:14 -0700 |
commit | 13a90e43acd40e0993790ac354eb7a5a3745a2b2 (patch) | |
tree | 341628d1474a4bcd5dcab469d5a8415a8c68f713 | |
parent | a6a7b53b6312ac06df87e501bf65340b457d0aaf (diff) | |
download | libusb-13a90e43acd40e0993790ac354eb7a5a3745a2b2.tar.gz |
linux_usbfs: Set reap action to CANCELLED only when successful
Prior to this commit, a call to libusb_cancel_transfer() would set
the reap action of the transfer to CANCELLED regardless of whether
the cancellation was successful or not. This can cause the transfer
status to incorrectly report LIBUSB_TRANSFER_CANCELLED when in some
cases this is not the case. This commit adds a check for a successful
cancellation before setting the reap action as such.
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
-rw-r--r-- | libusb/os/linux_usbfs.c | 22 | ||||
-rw-r--r-- | libusb/version_nano.h | 2 |
2 files changed, 11 insertions, 13 deletions
diff --git a/libusb/os/linux_usbfs.c b/libusb/os/linux_usbfs.c index 5164616..99136ad 100644 --- a/libusb/os/linux_usbfs.c +++ b/libusb/os/linux_usbfs.c @@ -2154,6 +2154,14 @@ static int op_cancel_transfer(struct usbi_transfer *itransfer) struct linux_transfer_priv *tpriv = usbi_transfer_get_os_priv(itransfer); struct libusb_transfer *transfer = USBI_TRANSFER_TO_LIBUSB_TRANSFER(itransfer); + int r; + + if (!tpriv->urbs) + return LIBUSB_ERROR_NOT_FOUND; + + r = discard_urbs(itransfer, 0, tpriv->num_urbs); + if (r != 0) + return r; switch (transfer->type) { case LIBUSB_TRANSFER_TYPE_BULK: @@ -2161,21 +2169,11 @@ static int op_cancel_transfer(struct usbi_transfer *itransfer) if (tpriv->reap_action == ERROR) break; /* else, fall through */ - case LIBUSB_TRANSFER_TYPE_CONTROL: - case LIBUSB_TRANSFER_TYPE_INTERRUPT: - case LIBUSB_TRANSFER_TYPE_ISOCHRONOUS: - tpriv->reap_action = CANCELLED; - break; default: - usbi_err(TRANSFER_CTX(transfer), - "unknown endpoint type %d", transfer->type); - return LIBUSB_ERROR_INVALID_PARAM; + tpriv->reap_action = CANCELLED; } - if (!tpriv->urbs) - return LIBUSB_ERROR_NOT_FOUND; - - return discard_urbs(itransfer, 0, tpriv->num_urbs); + return 0; } static void op_clear_transfer_priv(struct usbi_transfer *itransfer) diff --git a/libusb/version_nano.h b/libusb/version_nano.h index 7b92667..bdb6213 100644 --- a/libusb/version_nano.h +++ b/libusb/version_nano.h @@ -1 +1 @@ -#define LIBUSB_NANO 10994 +#define LIBUSB_NANO 10995 |