From patchwork Wed Feb 13 03:39:27 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thinh Nguyen X-Patchwork-Id: 10809065 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7DACF1390 for ; Wed, 13 Feb 2019 03:39:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5F4A52C3E7 for ; Wed, 13 Feb 2019 03:39:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4F9192C3F0; Wed, 13 Feb 2019 03:39:30 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DF75A2C3E7 for ; Wed, 13 Feb 2019 03:39:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730026AbfBMDj2 (ORCPT ); Tue, 12 Feb 2019 22:39:28 -0500 Received: from smtprelay.synopsys.com ([198.182.47.9]:59134 "EHLO smtprelay.synopsys.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728014AbfBMDj2 (ORCPT ); Tue, 12 Feb 2019 22:39:28 -0500 Received: from mailhost.synopsys.com (dc8-mailhost1.synopsys.com [10.13.135.209]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtprelay.synopsys.com (Postfix) with ESMTPS id 8625F24E16F5; Tue, 12 Feb 2019 19:39:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=synopsys.com; s=mail; t=1550029168; bh=2jd3a0AXdZjVnlaRddw3HYWFTGJH5Xs0YW03IkoQkbc=; h=Date:From:Subject:To:CC:From; b=KoXWdsZOJU3b1cWAdO78TJULHsumbQOJ+3cR7YHG9xHDvbdOdbji348A1Rr2dREXt LmKcPkzOoMEMlOC6Mt9tyKbHvKEzGslTDTMFh8RspuIi1oYFSc2NWf6aVu9Epgp6pg fprCmorGPHiNDj03b26yPeJdwuclsWJ5SM9A7I/WNX9Ve2w712WCT8W5lBkEmctf5C QD8SiapCo5q7dkv5cMrPwhgcduAbJlFQ95VeI07d21h1xLWFvYHxuGU+QUa6fzDmk6 sHNCfH26JTi+yIlHtsms3LGh4BL38MuJ9E4YzDiVGA3s2RIO1dHGJIfFfPBx3VKDBE z77vTLYJUYuuA== Received: from US01WEHTC2.internal.synopsys.com (us01wehtc2.internal.synopsys.com [10.12.239.237]) (using TLSv1.2 with cipher AES128-SHA256 (128/128 bits)) (No client certificate requested) by mailhost.synopsys.com (Postfix) with ESMTPS id 75C18A005A; Wed, 13 Feb 2019 03:39:28 +0000 (UTC) Received: from US01WEHTC1.internal.synopsys.com (10.12.239.236) by US01WEHTC2.internal.synopsys.com (10.12.239.237) with Microsoft SMTP Server (TLS) id 14.3.408.0; Tue, 12 Feb 2019 19:39:28 -0800 Received: from te-lab16 (10.13.184.20) by us01wehtc1.internal.synopsys.com (10.12.239.236) with Microsoft SMTP Server (TLS) id 14.3.408.0; Tue, 12 Feb 2019 19:39:27 -0800 Received: by te-lab16 (sSMTP sendmail emulation); Tue, 12 Feb 2019 19:39:27 -0800 Date: Tue, 12 Feb 2019 19:39:27 -0800 Message-ID: <84bb0bfc1a910cd99e23861451be603be790283b.1550029050.git.thinhn@synopsys.com> From: Thinh Nguyen Subject: [PATCH] usb: dwc3: Reset num_trbs after skipping To: Felipe Balbi , CC: John Youn , Thinh Nguyen MIME-Version: 1.0 X-Originating-IP: [10.13.184.20] Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- drivers/usb/dwc3/gadget.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c index e83f84e07f18..a1943723762b 100644 --- a/drivers/usb/dwc3/gadget.c +++ b/drivers/usb/dwc3/gadget.c @@ -1502,6 +1502,8 @@ static void dwc3_gadget_ep_skip_trbs(struct dwc3_ep *dep, struct dwc3_request *r 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)