Skip to content
Snippets Groups Projects
Commit 04ee6ee2 authored by Paul Kocialkowski's avatar Paul Kocialkowski Committed by Marek Vasut
Browse files

usb: Early failure when the first descriptor read fails or is invalid


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: default avatarPaul Kocialkowski <contact@paulk.fr>
parent 8879be88
No related branches found
No related tags found
No related merge requests found
...@@ -956,7 +956,7 @@ int usb_new_device(struct usb_device *dev) ...@@ -956,7 +956,7 @@ int usb_new_device(struct usb_device *dev)
*/ */
#ifndef CONFIG_USB_XHCI #ifndef CONFIG_USB_XHCI
err = usb_get_descriptor(dev, USB_DT_DEVICE, 0, desc, 64); err = usb_get_descriptor(dev, USB_DT_DEVICE, 0, desc, 64);
if (err < 0) { if (err < sizeof(struct usb_device_descriptor)) {
debug("usb_new_device: usb_get_descriptor() failed\n"); debug("usb_new_device: usb_get_descriptor() failed\n");
return -EIO; return -EIO;
} }
...@@ -996,6 +996,9 @@ int usb_new_device(struct usb_device *dev) ...@@ -996,6 +996,9 @@ int usb_new_device(struct usb_device *dev)
case 64: case 64:
dev->maxpacketsize = PACKET_SIZE_64; dev->maxpacketsize = PACKET_SIZE_64;
break; break;
default:
printf("usb_new_device: invalid max packet size\n");
return -EIO;
} }
dev->devnum = addr; dev->devnum = addr;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment