From 2d98e5499b42ca4feda390d5bd867aa956bf7f11 Mon Sep 17 00:00:00 2001 From: Dean Camera Date: Sat, 5 May 2012 19:43:06 +0000 Subject: Fixed possible deadlock in the CDC device driver if the USB connection is dropped while the CDC_REQ_SetLineEncoding control request is being processed by the stack (thanks to Jonathan Hudgins). --- LUFA/Drivers/USB/Class/Device/CDCClassDevice.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'LUFA/Drivers/USB/Class') diff --git a/LUFA/Drivers/USB/Class/Device/CDCClassDevice.c b/LUFA/Drivers/USB/Class/Device/CDCClassDevice.c index a16949cfd..ff0f9bb55 100644 --- a/LUFA/Drivers/USB/Class/Device/CDCClassDevice.c +++ b/LUFA/Drivers/USB/Class/Device/CDCClassDevice.c @@ -69,8 +69,12 @@ void CDC_Device_ProcessControlRequest(USB_ClassInfo_CDC_Device_t* const CDCInter { Endpoint_ClearSETUP(); - while (!(Endpoint_IsOUTReceived())); - + while (!(Endpoint_IsOUTReceived())) + { + if (USB_DeviceState == DEVICE_STATE_Unattached) + return; + } + CDCInterfaceInfo->State.LineEncoding.BaudRateBPS = Endpoint_Read_32_LE(); CDCInterfaceInfo->State.LineEncoding.CharFormat = Endpoint_Read_8(); CDCInterfaceInfo->State.LineEncoding.ParityType = Endpoint_Read_8(); -- cgit v1.2.3