Message ID | 1427624899-9537-3-git-send-email-contact@paulk.fr |
---|---|
State | Superseded |
Delegated to: | Marek Vasut |
Headers | show |
On Sunday, March 29, 2015 at 12:28:19 PM, Paul Kocialkowski wrote: > This may happen when using an USB1 device on a controller that only > supports USB2 (e.g. EHCI). Reading the first descriptor will fail (read 0 > byte), so we can abort the process at this point instead of failing later > and wasting time. > > Signed-off-by: Paul Kocialkowski <contact@paulk.fr> > --- Please just fix the return -1 (same thing Lukasz was complaining about in 1/3), I will pick it then. Thanks! Best regards, Marek Vasut
diff --git a/common/usb.c b/common/usb.c index 67e2350..fb00c95 100644 --- a/common/usb.c +++ b/common/usb.c @@ -956,8 +956,8 @@ int usb_new_device(struct usb_device *dev) */ #ifndef CONFIG_USB_XHCI err = usb_get_descriptor(dev, USB_DT_DEVICE, 0, desc, 64); - if (err < 0) { - debug("usb_new_device: usb_get_descriptor() failed\n"); + if (err < sizeof(struct usb_device_descriptor)) { + printf("usb_new_device: usb_get_descriptor() failed\n"); return -1; } @@ -996,6 +996,9 @@ int usb_new_device(struct usb_device *dev) case 64: dev->maxpacketsize = PACKET_SIZE_64; break; + default: + printf("usb_new_device: invalid max packet size\n"); + return -1; } dev->devnum = addr;
This may happen when using an USB1 device on a controller that only supports USB2 (e.g. EHCI). Reading the first descriptor will fail (read 0 byte), so we can abort the process at this point instead of failing later and wasting time. Signed-off-by: Paul Kocialkowski <contact@paulk.fr> --- common/usb.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)