summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorhselasky <hselasky@FreeBSD.org>2011-09-20 14:17:58 +0000
committerhselasky <hselasky@FreeBSD.org>2011-09-20 14:17:58 +0000
commit8139b983c9eac1660886071f4eac6efe6df8a8ec (patch)
tree241eacbd6ea6027af324d87fb64b99072d7732d3
parent8bc7d7cad3d228e3a46c274ca5a47bc0def7d0da (diff)
downloadFreeBSD-src-8139b983c9eac1660886071f4eac6efe6df8a8ec.zip
FreeBSD-src-8139b983c9eac1660886071f4eac6efe6df8a8ec.tar.gz
Avoid starting the USB transfer if an error is already pending.
This change fixes a race in device side mode during clear-stall from host, which can cause data to be sent too early on the given endpoint. Approved by: re (kib) MFC after: 1 week
-rw-r--r--sys/dev/usb/usb_transfer.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/sys/dev/usb/usb_transfer.c b/sys/dev/usb/usb_transfer.c
index d4c2408..cd7b2e2 100644
--- a/sys/dev/usb/usb_transfer.c
+++ b/sys/dev/usb/usb_transfer.c
@@ -2417,8 +2417,9 @@ usbd_transfer_start_cb(void *arg)
#if USB_HAVE_PF
usbpf_xfertap(xfer, USBPF_XFERTAP_SUBMIT);
#endif
- /* start the transfer */
- (ep->methods->start) (xfer);
+ /* start USB transfer, if no error */
+ if (xfer->error == 0)
+ (ep->methods->start) (xfer);
xfer->flags_int.can_cancel_immed = 1;
@@ -2597,8 +2598,9 @@ usbd_pipe_start(struct usb_xfer_queue *pq)
#if USB_HAVE_PF
usbpf_xfertap(xfer, USBPF_XFERTAP_SUBMIT);
#endif
- /* start USB transfer */
- (ep->methods->start) (xfer);
+ /* start USB transfer, if no error */
+ if (xfer->error == 0)
+ (ep->methods->start) (xfer);
xfer->flags_int.can_cancel_immed = 1;
OpenPOWER on IntegriCloud