diff options
| author | HiFiPHile <[email protected]> | 2026-09-04 07:00:15 +0200 |
|---|---|---|
| committer | HiFiPHile <[email protected]> | 2026-09-04 08:49:21 +0200 |
| commit | 47a432a3683a0dbc77de7e4ae3ddbbb9dffa98fd (patch) | |
| tree | 460318a1a027e24f8d53924a9d818f17386ba79b | |
| parent | b09f21f328e12c7296c554dbaad9e8d607cc17f3 (diff) | |
Fix HID configuration callback after teardown
| -rw-r--r-- | src/class/hid/hid_host.c | 12 |
1 files 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); |
