usb: dwc3: gadget: Fix list_del corruption in dwc3_ep_dequeue
Subsystems (2)
Hi Felipe,
Quoted 12 lines · Jack Pham
dwc3_ep_dequeue()waits for completion of End Transfer command usingwait_event_lock_irq(), which will release thedwc3->lockwhile waiting and reacquire after completion. This allows a potential race condition withep_disable()which also removes all requests fromstarted_listandpending_list. The check for NULLr->trbshould catch this but currently it exits to the wrong 'out1' label which callsdwc3_gadget_giveback(). Since its list entry was already removed, ifCONFIG_DEBUG_LISTis enabled a 'list_delcorruption' bug is thrown since its next/prev pointers are already LIST_POISON1/2. Ifr->trbis NULL it should simply exit to 'out0'.
Quoted 1 line
Fixes cf3113d893d4 ("usb: dwc3: gadget: properly increment dequeue pointer on ep_dequeue")
Upon taking a second look at this patch, and noting the subject of the Fixes tag here, one side effect of this fix is that dep->queued_requests won't get decremented. I see this is a counter for tracing purposes so probably doesn't affect function. But it begs the question of whether dwc3_remove_requests() as called from __dwc3_gadget_ep_disable() should have decremented this counter or even zeroed it out completely?
Review
Quoted 4 lines
(quoted diff) +1
-1if (!r->trb) - goto out1; + goto out0;
Thanks,
Jack