Re: [PATCH 4.19 113/125] usb: dwc3: gadget: fix race when disabling ep with cancelled xfers
From: Pavel Machek
Date: Wed Nov 13 2019 - 08:52:12 EST
Hi!
> From: Felipe Balbi <felipe.balbi@xxxxxxxxxxxxxxx>
>
> [ Upstream commit d8eca64eec7103ab1fbabc0a187dbf6acfb2af93 ]
>
> When disabling an endpoint which has cancelled requests, we should
> make sure to giveback requests that are currently pending in the
> cancelled list, otherwise we may fall into a situation where command
> completion interrupt fires after endpoint has been disabled, therefore
> causing a splat.
>
> Fixes: fec9095bdef4 "usb: dwc3: gadget: remove wait_end_transfer"
> Reported-by: Roger Quadros <rogerq@xxxxxx>
> Signed-off-by: Felipe Balbi <felipe.balbi@xxxxxxxxxxxxxxx>
> Link: https://lore.kernel.org/r/20191031090713.1452818-1-felipe.balbi@xxxxxxxxxxxxxxx
> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
> Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>
> ---
> drivers/usb/dwc3/gadget.c | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
> index 54de732550648..8398c33d08e7c 100644
> --- a/drivers/usb/dwc3/gadget.c
> +++ b/drivers/usb/dwc3/gadget.c
> @@ -698,6 +698,12 @@ static void dwc3_remove_requests(struct dwc3 *dwc, struct dwc3_ep *dep)
>
> dwc3_gadget_giveback(dep, req, -ESHUTDOWN);
> }
> +
> + while (!list_empty(&dep->cancelled_list)) {
> + req = next_request(&dep->cancelled_list);
> +
> + dwc3_gadget_giveback(dep, req, -ESHUTDOWN);
> + }
> }
This is third copy of a loop. Perhaps it is time to create a helper?
Best regards,
Pavel
--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Attachment:
signature.asc
Description: PGP signature