From a35ef797bc9d2de159fdc44e5c85c734cd1d0468 Mon Sep 17 00:00:00 2001 From: Piotr Ciura Date: Thu, 15 May 2025 09:38:21 +0200 Subject: [PATCH] drivers: usb: Prevent from perpetual locked state The USB CDC driver is unable to process any bulk IN transfers after receiving spurious 'Clear Feature - Endpoint Halt' request from host due to perpetual locked state caused by previously scheduled transfer, that will never be finished, as the endpoint's state is set to NAK. Fix by ignoring spurious request. Signed-off-by: Piotr Ciura --- drivers/usb/device/usb_dc_stm32.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/usb/device/usb_dc_stm32.c b/drivers/usb/device/usb_dc_stm32.c index 8ac737ef47884..0acab895a5a41 100644 --- a/drivers/usb/device/usb_dc_stm32.c +++ b/drivers/usb/device/usb_dc_stm32.c @@ -869,6 +869,10 @@ int usb_dc_ep_clear_stall(const uint8_t ep) return -EINVAL; } + if (!ep_state->ep_stalled) { + return 0; + } + status = HAL_PCD_EP_ClrStall(&usb_dc_stm32_state.pcd, ep); if (status != HAL_OK) { LOG_ERR("HAL_PCD_EP_ClrStall failed(0x%02x), %d", ep,