I've had different versions of this floating around for a while;
basically, the goal is to be more robust against devices that
misbehave by returning garbage descriptors in certain cases.

- Dave

Add an extra check when fetching descriptors:  the type must be
correct.  This guards against different types of firmware (or maybe
hardware) errors than the two checks already being made.

Signed-off-by: David Brownell <[EMAIL PROTECTED]>

--- 1.64/drivers/usb/core/message.c     Wed Jun 30 06:48:12 2004
+++ edited/drivers/usb/core/message.c   Wed Jul 14 12:05:11 2004
@@ -577,8 +577,13 @@
                                USB_REQ_GET_DESCRIPTOR, USB_DIR_IN,
                                (type << 8) + index, 0, buf, size,
                                HZ * USB_CTRL_GET_TIMEOUT);
-               if (!(result == 0 || result == -EPIPE))
-                       break;
+               if (result == 0 || result == -EPIPE)
+                       continue;
+               if (result > 1 && ((u8 *)buf)[1] != type) {
+                       retval = -EPROTO;
+                       continue;
+               }
+               break;
        }
        return result;
 }

Reply via email to