From 47a432a3683a0dbc77de7e4ae3ddbbb9dffa98fd Mon Sep 17 00:00:00 2001 From: HiFiPHile Date: Fri, 4 Sep 2026 07:00:15 +0200 Subject: Fix HID configuration callback after teardown --- src/class/hid/hid_host.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/class/hid/hid_host.c b/src/class/hid/hid_host.c index ca3654acb..8410329ad 100644 --- a/src/class/hid/hid_host.c +++ b/src/class/hid/hid_host.c @@ -574,12 +574,12 @@ bool hidh_set_config(uint8_t daddr, uint8_t itf_num) { } static void process_set_config(tuh_xfer_t* xfer) { - // Stall is a valid response for SET_IDLE, sometime SET_PROTOCOL as well - // therefore we could ignore its result - if (!(xfer->setup->bRequest == HID_REQ_CONTROL_SET_IDLE || - xfer->setup->bRequest == HID_REQ_CONTROL_SET_PROTOCOL)) { - TU_ASSERT(xfer->result == XFER_RESULT_SUCCESS,); - } + // Stall is a valid response for SET_IDLE, sometimes SET_PROTOCOL as well. + // Other failures include teardown cancellation and must not advance configuration. + const bool stall_ok = xfer->result == XFER_RESULT_STALLED && + (xfer->setup->bRequest == HID_REQ_CONTROL_SET_IDLE || + xfer->setup->bRequest == HID_REQ_CONTROL_SET_PROTOCOL); + TU_VERIFY(xfer->result == XFER_RESULT_SUCCESS || stall_ok,); uintptr_t const state = xfer->user_data; uint8_t const itf_num = (uint8_t) tu_le16toh(xfer->setup->wIndex); -- cgit v1.3.1