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>
*/
#ifndef CONFIG_USB_XHCI
err = usb_get_descriptor(dev, USB_DT_DEVICE, 0, desc, 64);
*/
#ifndef CONFIG_USB_XHCI
err = usb_get_descriptor(dev, USB_DT_DEVICE, 0, desc, 64);
+ if (err < sizeof(struct usb_device_descriptor)) {
debug("usb_new_device: usb_get_descriptor() failed\n");
return -EIO;
}
debug("usb_new_device: usb_get_descriptor() failed\n");
return -EIO;
}
case 64:
dev->maxpacketsize = PACKET_SIZE_64;
break;
case 64:
dev->maxpacketsize = PACKET_SIZE_64;
break;
+ default:
+ printf("usb_new_device: invalid max packet size\n");
+ return -EIO;