]> git.hungrycats.org Git - linux/commitdiff
[PATCH] usb_submit_urb fix for broken usb devices
authorGreg Kroah-Hartman <greg@kroah.com>
Mon, 13 May 2002 07:48:05 +0000 (00:48 -0700)
committerGreg Kroah-Hartman <greg@kroah.com>
Mon, 13 May 2002 07:48:05 +0000 (00:48 -0700)
added check for wMaxPacketSize of 0, which is a messed up device, but
seems to be legal according to the USB spec.

Thanks to Johannes for figuring out the problem, and providing an
original version of this patch.

drivers/usb/core/usb.c

index be4737a42201c2416ea42dea1ca6af4fb4307db9..75cd49403bb8b8ca4df5cdf6661cead22f1d404f 100644 (file)
@@ -1162,10 +1162,15 @@ struct urb * usb_get_urb(struct urb *urb)
  */
 int usb_submit_urb(struct urb *urb, int mem_flags)
 {
-       if (urb && urb->dev && urb->dev->bus && urb->dev->bus->op)
+
+       if (urb && urb->dev && urb->dev->bus && urb->dev->bus->op) {
+               if (usb_maxpacket(urb->dev, urb->pipe, usb_pipeout(urb->pipe)) <= 0) {
+                       err("%s: pipe %x has invalid size (<= 0)", __FUNCTION__, urb->pipe);
+                       return -EMSGSIZE;
+               }
                return urb->dev->bus->op->submit_urb(urb, mem_flags);
-       else
-               return -ENODEV;
+       }
+       return -ENODEV;
 }
 
 /*-------------------------------------------------------------------*/