Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp2535826yba; Mon, 6 May 2019 07:39:11 -0700 (PDT) X-Google-Smtp-Source: APXvYqztmgD4dfkp/XkK6RyjcO18j4Qp1LwEsEd8QRq1eLjlM+qy/JDyUC3L0IzFrz79MJTXG5/w X-Received: by 2002:a17:902:f085:: with SMTP id go5mr32688967plb.292.1557153551437; Mon, 06 May 2019 07:39:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557153551; cv=none; d=google.com; s=arc-20160816; b=TqTo7BIQ2ZZTx3iQVPxfDuAFKERaoVPZqkiv7giEpHdq8utw1aU1r5FCuT5aIi/5xX yMA89C6HI1xURUURG1W77RI6KhS01jU4WUgn7kcHM2+p6nyHeZAGHZjrxTA8bsH65orr zajbKoS/eHkb94U3JkwJugUcUjHZJWgC4phvNSxx0yIHLLm/xMh8tbCghlzwpSmJ5luw l8O6Ojn5/4fHntwe//Fydymj1T52vB7UrrR//+08/nggnEJEw9WqZZQXywpPWquE+9m5 fWtKRHoJCoR7jeOw+WbzWInP0DJFsm+U5UjP6YrkK11cpse6FQIAsl85KUKvqohb77bc PyQQ== 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=olCojlKiwIvjuQO6Vd3EU2JgOWjh86wLEKJwt2dyszw=; b=mlwDyZSZqWGUeLrdldg8mdRP0pMe6Y5yp/ZaP8xwSCicwiJo2ZA4YXdfKfioTIW3D3 rrjsPjvQ5jvjzxlHJq8+iREgFyu3HbKa4OEMn1v/E36zAJna8fFWVWVo8LV/b0A5IpYX yn+cR7xwPhhnK2OMzbAn43WggsamVgfHD9qugDcLIACcvRnM0EvrGKHgjpiIbeL8nzuz 2VIyHz8g9V/oYq+aYBTDMgWbIvwdN/LpAw2cUKUBWVtgmnx6wLrBP18QKRFQek2yoUzb qAQYo3tZcDHOMDJv4otGmN0DpR9PBacQFsNsiB8trUv8myOwc4NvHk9jedTicwnmQ13L ZmqA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ykHBRGXG; 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 s16si10185982pga.544.2019.05.06.07.38.54; Mon, 06 May 2019 07:39:11 -0700 (PDT) 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=ykHBRGXG; 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 S1727356AbfEFOhR (ORCPT + 99 others); Mon, 6 May 2019 10:37:17 -0400 Received: from mail.kernel.org ([198.145.29.99]:57862 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726896AbfEFOhM (ORCPT ); Mon, 6 May 2019 10:37:12 -0400 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 9DCCC204EC; Mon, 6 May 2019 14:37:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1557153432; bh=dONN9DZiWm0DxeP39EVsGqhgAn8epP3pcjSbJ8wX0jY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ykHBRGXGU272QHHZFGhjtAw5+1kOXxLyJJ2ByvgcyPO00mIq0ZBf3Q1USLJtwGP0/ Nb3hxiZqPjx1GVUJ+koBwxOC9SntEfjUp1HvD9CIQNobnjIaPGw7V6tiSV8BWq09R7 hUvitYp5oPSSn53rllt5fCQLIkTw38pushj22xtk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Thinh Nguyen , Felipe Balbi Subject: [PATCH 5.0 087/122] usb: dwc3: Reset num_trbs after skipping Date: Mon, 6 May 2019 16:32:25 +0200 Message-Id: <20190506143102.546646600@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190506143054.670334917@linuxfoundation.org> References: <20190506143054.670334917@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: Thinh Nguyen commit c7152763f02e05567da27462b2277a554e507c89 upstream. Currently req->num_trbs is not reset after the TRBs are skipped and processed from the cancelled list. The gadget driver may reuse the request with an invalid req->num_trbs, and DWC3 will incorrectly skip trbs. To fix this, simply reset req->num_trbs to 0 after skipping through all of them. Fixes: c3acd5901414 ("usb: dwc3: gadget: use num_trbs when skipping TRBs on ->dequeue()") Signed-off-by: Thinh Nguyen Signed-off-by: Felipe Balbi Signed-off-by: Greg Kroah-Hartman --- drivers/usb/dwc3/gadget.c | 2 ++ 1 file changed, 2 insertions(+) --- a/drivers/usb/dwc3/gadget.c +++ b/drivers/usb/dwc3/gadget.c @@ -1506,6 +1506,8 @@ static void dwc3_gadget_ep_skip_trbs(str trb->ctrl &= ~DWC3_TRB_CTRL_HWO; dwc3_ep_inc_deq(dep); } + + req->num_trbs = 0; } static void dwc3_gadget_ep_cleanup_cancelled_requests(struct dwc3_ep *dep)