summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2016-06-09 22:06:30 -0700
committerKeith Packard <keithp@keithp.com>2016-06-09 22:06:30 -0700
commit36ba97fabbed2f2a4a89da5be221c630ea3ff66f (patch)
tree1079b6fe41e5bcb6ab8516bdba034ea9dbb0e198 /src
parent2970de9f92243b11d3beef56f3b1df3ef3579b95 (diff)
stmf0: Do not send more data than requested for GET_DESCRIPTOR
When Linux boots, it asks for only the first 8 bytes of the device descriptor; we must limit the amount of data sent back to that amount or USB will get wedged. Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'src')
-rw-r--r--src/stmf0/ao_usb_stm.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/stmf0/ao_usb_stm.c b/src/stmf0/ao_usb_stm.c
index a67fc868..63b35b24 100644
--- a/src/stmf0/ao_usb_stm.c
+++ b/src/stmf0/ao_usb_stm.c
@@ -683,7 +683,7 @@ ao_usb_serial_init(void)
/* Walk through the list of descriptors and find a match
*/
static void
-ao_usb_get_descriptor(uint16_t value)
+ao_usb_get_descriptor(uint16_t value, uint16_t length)
{
const uint8_t *descriptor;
uint8_t type = value >> 8;
@@ -704,6 +704,8 @@ ao_usb_get_descriptor(uint16_t value)
len = sizeof (ao_usb_serial);
}
#endif
+ if (len > length)
+ len = length;
ao_usb_ep0_in_set(descriptor, len);
break;
}
@@ -748,7 +750,7 @@ ao_usb_ep0_setup(void)
break;
case AO_USB_REQ_GET_DESCRIPTOR:
debug ("get descriptor %d\n", ao_usb_setup.value);
- ao_usb_get_descriptor(ao_usb_setup.value);
+ ao_usb_get_descriptor(ao_usb_setup.value, ao_usb_setup.length);
break;
case AO_USB_REQ_GET_CONFIGURATION:
debug ("get configuration %d\n", ao_usb_configuration);