# This is a BitKeeper generated patch for the following project:
# Project Name: Linux kernel tree
# This patch format is intended for GNU patch command version 2.5 or higher.
# This patch includes the following deltas:
#	           ChangeSet	1.544   -> 1.545  
#	drivers/usb/core/usb.c	1.51    -> 1.52   
#
# The following is the BitKeeper ChangeSet Log
# --------------------------------------------
# 02/05/13	greg@kroah.com	1.545
# [PATCH] usb_submit_urb fix for broken usb devices
# 
# 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.
# --------------------------------------------
#
diff -Nru a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
--- a/drivers/usb/core/usb.c	Mon May 13 15:53:51 2002
+++ b/drivers/usb/core/usb.c	Mon May 13 15:53:51 2002
@@ -1162,10 +1162,15 @@
  */
 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;
 }
 
 /*-------------------------------------------------------------------*/
