ChangeSet 1.1807.48.29, 2004/08/02 16:24:07-07:00, [EMAIL PROTECTED]

[PATCH] USB: usb_get_descriptor, more error checks

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.

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]>
Signed-off-by: Greg Kroah-Hartman <[EMAIL PROTECTED]>


 drivers/usb/core/message.c |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)


diff -Nru a/drivers/usb/core/message.c b/drivers/usb/core/message.c
--- a/drivers/usb/core/message.c        2004-08-23 13:19:34 -07:00
+++ b/drivers/usb/core/message.c        2004-08-23 13:19:34 -07:00
@@ -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;
 }



-------------------------------------------------------
SF.Net email is sponsored by Shop4tech.com-Lowest price on Blank Media
100pk Sonic DVD-R 4x for only $29 -100pk Sonic DVD+R for only $33
Save 50% off Retail on Ink & Toner - Free Shipping and Free Gift.
http://www.shop4tech.com/z/Inkjet_Cartridges/9_108_r285
_______________________________________________
[EMAIL PROTECTED]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

Reply via email to