lkml.org 
[lkml]   [2019]   [Nov]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 4.19 113/125] usb: dwc3: gadget: fix race when disabling ep with cancelled xfers
Hi!

> From: Felipe Balbi <felipe.balbi@linux.intel.com>
>
> [ 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@ti.com>
> Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
> Link: https://lore.kernel.org/r/20191031090713.1452818-1-felipe.balbi@linux.intel.com
> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Signed-off-by: Sasha Levin <sashal@kernel.org>
> ---
> 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
[unhandled content-type:application/pgp-signature]
\
 
 \ /
  Last update: 2019-11-13 14:52    [W:0.448 / U:0.316 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site