USB: report submission of active URBs
authorAlan Stern <stern@rowland.harvard.edu>
Wed, 7 Nov 2012 21:35:00 +0000 (16:35 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 12 Nov 2012 02:10:46 +0000 (18:10 -0800)
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>
Documentation/usb/error-codes.txt
drivers/usb/core/urb.c

index 8d1e2a9ebbba25a2736690877c524927eb96b0b1..9c3eb845ebe514f20ddeacbfc644bb79d700153c 100644 (file)
@@ -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
index 3662287e2f4feadd4876fad2d37072f70c065fce..e0d9d948218c665ce09730c00730757a5c33986e 100644 (file)
@@ -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;