kernel/USB-report-submission-of-active-URBs.patch

47 lines
1.5 KiB
Diff

commit 2f02bc8af3abb846823811af65ec6cc46a4d525d
Author: Alan Stern <stern@rowland.harvard.edu>
Date: Wed Nov 7 16:35:00 2012 -0500
USB: report submission of active URBs
This patch (as1633) changes slightly the way usbcore handled
submissions of URBs that are already active. It will now return
-EBUSY rather than -EINVAL, and it will call WARN_ONCE to draw
people's attention to the bug.
Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
diff --git a/Documentation/usb/error-codes.txt b/Documentation/usb/error-codes.txt
index 8d1e2a9..9c3eb84 100644
--- a/Documentation/usb/error-codes.txt
+++ b/Documentation/usb/error-codes.txt
@@ -21,6 +21,8 @@ Non-USB-specific:
USB-specific:
+-EBUSY The URB is already active.
+
-ENODEV specified USB-device or bus doesn't exist
-ENOENT specified interface or endpoint does not exist or
diff --git a/drivers/usb/core/urb.c b/drivers/usb/core/urb.c
index 3662287..e0d9d94 100644
--- a/drivers/usb/core/urb.c
+++ b/drivers/usb/core/urb.c
@@ -321,8 +321,13 @@ int usb_submit_urb(struct urb *urb, gfp_t mem_flags)
struct usb_host_endpoint *ep;
int is_out;
- if (!urb || urb->hcpriv || !urb->complete)
+ if (!urb || !urb->complete)
return -EINVAL;
+ if (urb->hcpriv) {
+ WARN_ONCE(1, "URB %p submitted while active\n", urb);
+ return -EBUSY;
+ }
+
dev = urb->dev;
if ((!dev) || (dev->state < USB_STATE_UNAUTHENTICATED))
return -ENODEV;