Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp2026423ybc; Wed, 13 Nov 2019 07:56:34 -0800 (PST) X-Google-Smtp-Source: APXvYqypFB9QTSHHSA5mvf1cUJHgzV1crroZSTqEEMjjuMM4w3md1rTmqYJqzmH7a9sIjeObXu8X X-Received: by 2002:a17:906:344c:: with SMTP id d12mr3326601ejb.227.1573660594634; Wed, 13 Nov 2019 07:56:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573660594; cv=none; d=google.com; s=arc-20160816; b=KjA3Mg4j81DZbdyP4lCI6J8/Vq2/fZ3jnR8OOOLQcnxFg05/xQl2IGCDYOJl5WIMcE MkshoZUtS72Idv0/r/MXA1uG3nWD8YvnC0KcO57cWxE3kXBCT2k2+3B5qHAgEBGd+GVA xw9FUv+t5KG9/Nxc8DioLXUcJeixCbQTbwu0OpqNYlMOAdRpH99DF2TGprA4nbsqnKAs e6v1YKdDQrmeClGAeZ7nm/I7YFUldzVq9V1wIzPyA/kTJgfJ/3Viv8iUV16FaNPvJ6CS RFXvEi62ndRiLIk/gYArTmjArYpY1U4f0gv1WRU8RQZBUdaF5cYl2raVvZDkf0DZzqQD vjmg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=Ahjwstfdll3wrrgDz9MPmxYNWFAGM6KIYlRbXWIZjHM=; b=mmnDzuQrVIVWyXPlf+WjKFwcWU8BP/th4TtgR+qUZv74GKYebFShvhV4Yg16y0q55z u3X4m3o0hLRCpLCtryAUEvp+VcV454bIHyl46qSaCSWoe6niroDg2w5XiBmvQe9qfjVl ypt46dRTE6NopMzfcXuvuCZpajsif73hlFAcMVrW9qMtMVLOLjh1r8987JCs+zbUkk0I XKYk1QgngVLDoaB+5sOuumpLBNLW+UZNZF4XogEnb83GZxMKLOVpTQLqUpBZOotNAXju DPoPMHJ81wb2qo0LZDxKMTBJNn/erF7NbFB6j1rEUl1mZrqK4HA0jE2SYHAbAwJ3tGQR U66Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q12si1460331ejt.308.2019.11.13.07.56.10; Wed, 13 Nov 2019 07:56:34 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727431AbfKMNwL (ORCPT + 99 others); Wed, 13 Nov 2019 08:52:11 -0500 Received: from jabberwock.ucw.cz ([46.255.230.98]:47828 "EHLO jabberwock.ucw.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726957AbfKMNwL (ORCPT ); Wed, 13 Nov 2019 08:52:11 -0500 Received: by jabberwock.ucw.cz (Postfix, from userid 1017) id A2DFF1C1250; Wed, 13 Nov 2019 14:52:09 +0100 (CET) Date: Wed, 13 Nov 2019 14:52:09 +0100 From: Pavel Machek To: pavel@denx.de Cc: linux-kernel@vger.kernel.org, Roger Quadros , Felipe Balbi , Sasha Levin Subject: Re: [PATCH 4.19 113/125] usb: dwc3: gadget: fix race when disabling ep with cancelled xfers Message-ID: <20191113135209.GB20980@duo.ucw.cz> References: <20191111181438.945353076@linuxfoundation.org> <20191111181454.916507789@linuxfoundation.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="z6Eq5LdranGa6ru8" Content-Disposition: inline In-Reply-To: <20191111181454.916507789@linuxfoundation.org> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --z6Eq5LdranGa6ru8 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi! > From: Felipe Balbi >=20 > [ Upstream commit d8eca64eec7103ab1fbabc0a187dbf6acfb2af93 ] >=20 > 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. >=20 > Fixes: fec9095bdef4 "usb: dwc3: gadget: remove wait_end_transfer" > Reported-by: Roger Quadros > Signed-off-by: Felipe Balbi > Link: https://lore.kernel.org/r/20191031090713.1452818-1-felipe.balbi@lin= ux.intel.com > Signed-off-by: Greg Kroah-Hartman > Signed-off-by: Sasha Levin > --- > drivers/usb/dwc3/gadget.c | 6 ++++++ > 1 file changed, 6 insertions(+) >=20 > 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, s= truct dwc3_ep *dep) > =20 > dwc3_gadget_giveback(dep, req, -ESHUTDOWN); > } > + > + while (!list_empty(&dep->cancelled_list)) { > + req =3D 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 --=20 (english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blo= g.html --z6Eq5LdranGa6ru8 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iF0EABECAB0WIQRPfPO7r0eAhk010v0w5/Bqldv68gUCXcwKiQAKCRAw5/Bqldv6 8ixSAKCflMLincjXXFUMPrtOaJvWPURdqgCfXnLt5LhqLyDYBsUy8nhX0Yo05tM= =a3RU -----END PGP SIGNATURE----- --z6Eq5LdranGa6ru8--