aboutsummaryrefslogtreecommitdiff
path: root/lib/usb/usb_standard.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/usb/usb_standard.c')
-rw-r--r--lib/usb/usb_standard.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/usb/usb_standard.c b/lib/usb/usb_standard.c
index 5995387..aa92010 100644
--- a/lib/usb/usb_standard.c
+++ b/lib/usb/usb_standard.c
@@ -98,6 +98,11 @@ static int usb_standard_get_descriptor(struct usb_setup_data *req,
if (!_usbd_device.strings)
return 0; /* Device doesn't support strings. */
+ /* Check that string index is in range */
+ for(i = 0; i <= (req->wValue & 0xff); i++)
+ if(_usbd_device.strings[i] == NULL)
+ return 0;
+
sd->bLength = strlen(_usbd_device.strings[req->wValue & 0xff])
* 2 + 2;
sd->bDescriptorType = USB_DT_STRING;
@@ -131,6 +136,12 @@ static int usb_standard_set_address(struct usb_setup_data *req, u8 **buf,
_usbd_device.current_address = req->wValue;
+ /* Special workaround for STM32F10[57] that require the address
+ * to be set here. This is undocumented!
+ */
+ if(_usbd_device.driver == &stm32f107_usb_driver)
+ _usbd_device.driver->set_address(req->wValue);
+
return 1;
}