Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp6550448ybx; Mon, 11 Nov 2019 10:48:04 -0800 (PST) X-Google-Smtp-Source: APXvYqwnT2zU5Sab1R5LGQZnsC2TO56WyWy2CoFLFjh+1bxEX3ig64ILNpjfCTt4NHynCzcR2B06 X-Received: by 2002:a17:907:2061:: with SMTP id qp1mr24874637ejb.43.1573498084772; Mon, 11 Nov 2019 10:48:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573498084; cv=none; d=google.com; s=arc-20160816; b=gn0vqauvXlD3FYiUOfSpA/1fUkD42/JFie2ZnlR8nJ7cwlOoXvmiuyDPh5arrls0xi YSnmMa0piMl/+mSeErG8NrVSB5TTzBDfbWXDHFtJnbAjnKpnLGiXtocdeDz08XkQMHMo CkFAzYP7nevVbAfhxXP30JM0PmKvPazZI0c9Z6LyQWNQYVkjh5qA63vlh8TBeCQi5yaj B5ttFeXYWwfuKFP1qFyMhKr/101TDP44pcansZsD5EA8kp8+JG13UuSwBpONvS66kAKG jDkFueIuMjuqN7Gv0AZfivotOQTWWIyjOA1bpr9b2PGK5uK5aC5eFA6n9md4POtwDSp/ 3+pg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=BGgFAlDTukCXoV7L49OdsSpgLfOOaU28htqgtm1MnbA=; b=dE2SdAPoBhRemuGp8ZK7DsZevhcIDcnW35HD/ANcLzzEcL2n/XyKVRW9QxlSbT72wH FwHPewKJ0fcmIKsVix45hDZ15DtOOTpogbGGxiqe5hqHFqNs8e6ihgAgKgcNv8dwpBW1 wgNcRiTgQK2wjig+Hjgk8kReo4vGFZkctcvvxOSPV5iw6SY1IhBb+64tIxpFMFB4R+YK e7pF+fXvAoZjVYVzpUn4juA55ysand0McGWO/qpg2xxPFgPYTPWfc/+zv/Nu+n3UNmTG 5mDoUskOiPSVp5M9PSySe6Apbf5W5Xt1/v0eKA6hknW/5Fzbqn3kxLC8IRa3SIAloUAf /V0g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Pnz+9rZv; 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 e15si11719263eda.106.2019.11.11.10.47.40; Mon, 11 Nov 2019 10:48:04 -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; dkim=pass header.i=@kernel.org header.s=default header.b=Pnz+9rZv; 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 S1729993AbfKKSqZ (ORCPT + 99 others); Mon, 11 Nov 2019 13:46:25 -0500 Received: from mail.kernel.org ([198.145.29.99]:38828 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729984AbfKKSqW (ORCPT ); Mon, 11 Nov 2019 13:46:22 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 96AB02173B; Mon, 11 Nov 2019 18:46:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1573497981; bh=c33AECLfdkLw9jMvT37q32hJX80dIXfiA4ZnBHOxKt8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Pnz+9rZvSoYokpfFvwUgPrU2xdeks/uJR33Ll4AGP0HsNtNaOs277koKX++yA3nVS +TjZBC6A+PUGaSBW5hWx25q4vnqu2bHub/R3i57BS9yw6AxB8Z6iRsYEWC75r4G/tB n6C/xj4wOzUsrCWyUB1Io7fhi/4IS+yeEcSEqXoE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Roger Quadros , Felipe Balbi , Sasha Levin Subject: [PATCH 4.19 113/125] usb: dwc3: gadget: fix race when disabling ep with cancelled xfers Date: Mon, 11 Nov 2019 19:29:12 +0100 Message-Id: <20191111181454.916507789@linuxfoundation.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191111181438.945353076@linuxfoundation.org> References: <20191111181438.945353076@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Felipe Balbi [ 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 Signed-off-by: Felipe Balbi Link: https://lore.kernel.org/r/20191031090713.1452818-1-felipe.balbi@linux.intel.com Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- 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); + } } /** -- 2.20.1