diff options
author | Dean Camera <dean@fourwalledcubicle.com> | 2011-11-09 12:29:14 +0000 |
---|---|---|
committer | Dean Camera <dean@fourwalledcubicle.com> | 2011-11-09 12:29:14 +0000 |
commit | 8df0cf3241ff7de055850b630e8d878d1023bb5d (patch) | |
tree | 975339ab7029b43e3c4760d66d5128e55a5a07ce /LUFA/Drivers/USB/Class/Device | |
parent | 2b54cd984dbd9a56ae79f3f9733f088edcc12150 (diff) | |
download | lufa-8df0cf3241ff7de055850b630e8d878d1023bb5d.tar.gz lufa-8df0cf3241ff7de055850b630e8d878d1023bb5d.tar.bz2 lufa-8df0cf3241ff7de055850b630e8d878d1023bb5d.zip |
Fixed race conditions in the CDC, HID and Mass Storage class drivers when processing some control requests.
Diffstat (limited to 'LUFA/Drivers/USB/Class/Device')
-rw-r--r-- | LUFA/Drivers/USB/Class/Device/CDC.c | 10 | ||||
-rw-r--r-- | LUFA/Drivers/USB/Class/Device/HID.c | 2 | ||||
-rw-r--r-- | LUFA/Drivers/USB/Class/Device/MassStorage.c | 1 |
3 files changed, 12 insertions, 1 deletions
diff --git a/LUFA/Drivers/USB/Class/Device/CDC.c b/LUFA/Drivers/USB/Class/Device/CDC.c index dc8c1e7a6..29e5c25eb 100644 --- a/LUFA/Drivers/USB/Class/Device/CDC.c +++ b/LUFA/Drivers/USB/Class/Device/CDC.c @@ -51,10 +51,14 @@ void CDC_Device_ProcessControlRequest(USB_ClassInfo_CDC_Device_t* const CDCInter if (USB_ControlRequest.bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE)) { Endpoint_ClearSETUP(); + + while (!(Endpoint_IsINReady())); + Endpoint_Write_32_LE(CDCInterfaceInfo->State.LineEncoding.BaudRateBPS); Endpoint_Write_8(CDCInterfaceInfo->State.LineEncoding.CharFormat); Endpoint_Write_8(CDCInterfaceInfo->State.LineEncoding.ParityType); Endpoint_Write_8(CDCInterfaceInfo->State.LineEncoding.DataBits); + Endpoint_ClearIN(); Endpoint_ClearStatusStage(); } @@ -64,13 +68,17 @@ void CDC_Device_ProcessControlRequest(USB_ClassInfo_CDC_Device_t* const CDCInter if (USB_ControlRequest.bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE)) { Endpoint_ClearSETUP(); + + while (!(Endpoint_IsOUTReceived())); + CDCInterfaceInfo->State.LineEncoding.BaudRateBPS = Endpoint_Read_32_LE(); CDCInterfaceInfo->State.LineEncoding.CharFormat = Endpoint_Read_8(); CDCInterfaceInfo->State.LineEncoding.ParityType = Endpoint_Read_8(); CDCInterfaceInfo->State.LineEncoding.DataBits = Endpoint_Read_8(); + Endpoint_ClearOUT(); Endpoint_ClearStatusStage(); - + EVENT_CDC_Device_LineEncodingChanged(CDCInterfaceInfo); } diff --git a/LUFA/Drivers/USB/Class/Device/HID.c b/LUFA/Drivers/USB/Class/Device/HID.c index 3b0f87a61..ec02138ab 100644 --- a/LUFA/Drivers/USB/Class/Device/HID.c +++ b/LUFA/Drivers/USB/Class/Device/HID.c @@ -94,6 +94,7 @@ void HID_Device_ProcessControlRequest(USB_ClassInfo_HID_Device_t* const HIDInter if (USB_ControlRequest.bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE)) { Endpoint_ClearSETUP(); + while (!(Endpoint_IsINReady())); Endpoint_Write_8(HIDInterfaceInfo->State.UsingReportProtocol); Endpoint_ClearIN(); Endpoint_ClearStatusStage(); @@ -124,6 +125,7 @@ void HID_Device_ProcessControlRequest(USB_ClassInfo_HID_Device_t* const HIDInter if (USB_ControlRequest.bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE)) { Endpoint_ClearSETUP(); + while (!(Endpoint_IsINReady())); Endpoint_Write_8(HIDInterfaceInfo->State.IdleCount >> 2); Endpoint_ClearIN(); Endpoint_ClearStatusStage(); diff --git a/LUFA/Drivers/USB/Class/Device/MassStorage.c b/LUFA/Drivers/USB/Class/Device/MassStorage.c index 9d5ff7d20..7586c2812 100644 --- a/LUFA/Drivers/USB/Class/Device/MassStorage.c +++ b/LUFA/Drivers/USB/Class/Device/MassStorage.c @@ -61,6 +61,7 @@ void MS_Device_ProcessControlRequest(USB_ClassInfo_MS_Device_t* const MSInterfac if (USB_ControlRequest.bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE)) { Endpoint_ClearSETUP(); + while (!(Endpoint_IsINReady())); Endpoint_Write_8(MSInterfaceInfo->Config.TotalLUNs - 1); Endpoint_ClearIN(); Endpoint_ClearStatusStage(); |