Skip to content

Commit

Permalink
Probable race condition causes enumeration failure.
Browse files Browse the repository at this point in the history
setup_count is a uint8_t: we must check that it is > 0 before decrementing it, otherwise it takes a high positive value, the following if condition is true and the setup doesn't take place.
  • Loading branch information
MrMep committed Jul 7, 2024
1 parent e034538 commit d67fd82
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/device/usbd.c
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,7 @@ void tud_task_ext(uint32_t timeout_ms, bool in_isr) {
break;

case DCD_EVENT_SETUP_RECEIVED:
_usbd_dev.setup_count--;
if (_usbd_dev.setup_count > 0) _usbd_dev.setup_count--;
TU_LOG_BUF(CFG_TUD_LOG_LEVEL, &event.setup_received, 8);
if (_usbd_dev.setup_count) {
TU_LOG_USBD(" Skipped since there is other SETUP in queue\r\n");
Expand Down

0 comments on commit d67fd82

Please sign in to comment.