From patchwork Sat May 5 08:30:16 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Artur Petrosyan X-Patchwork-Id: 10382013 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 11BAE60236 for ; Sat, 5 May 2018 08:30:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F3364294E8 for ; Sat, 5 May 2018 08:30:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E39F6294CF; Sat, 5 May 2018 08:30:22 +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=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI, T_DKIM_INVALID 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 2BEBB294CF for ; Sat, 5 May 2018 08:30:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751211AbeEEIaS (ORCPT ); Sat, 5 May 2018 04:30:18 -0400 Received: from smtprelay.synopsys.com ([198.182.37.59]:47447 "EHLO smtprelay.synopsys.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750764AbeEEIaR (ORCPT ); Sat, 5 May 2018 04:30:17 -0400 Received: from mailhost.synopsys.com (mailhost3.synopsys.com [10.12.238.238]) by smtprelay.synopsys.com (Postfix) with ESMTP id 745261E149E for ; Sat, 5 May 2018 10:30:16 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=synopsys.com; s=mail; t=1525509016; bh=bac/p2UbDySN9VPrWTAyNhozwSIZFNsINRakHx8mw/M=; h=Date:From:Subject:To:CC:From; b=Zig7PYoaSQ8IhEfor87BI+F1kkrcehqVki211E9mSC55HPqUnU6CM6d8ubnxcmhny EUOMCWDqeEw+ncGI1FwEUN46xROc+lxePl7t9uW1KQWY7Q4Q46luWMbN/hGw9QchPR 4+rWzcaeiLr0wC4Whu85+G1NfN30fsB+PeuTTDpjaivJSnl1eLX8+l8mByLfirbVx+ SQcpoz4F4/S4+/Ylazs7vCELJgYh4LckNj8RRg/Y2HYD2xNiSB6tgOdXV2bt7Ak7E1 CUUMN4qUqtA4sh4Pic7ZSjfMspMQFXoxh21Fk0cHLty5cvyc9+7GaTTHxDURFVwU4H QrAa9Zgoo7/1Q== Received: from US01WXQAHTC1.internal.synopsys.com (us01wxqahtc1.internal.synopsys.com [10.12.238.230]) by mailhost.synopsys.com (Postfix) with ESMTP id D5454340D; Sat, 5 May 2018 01:30:15 -0700 (PDT) Received: from US01WEHTC1.internal.synopsys.com (10.12.239.236) by US01WXQAHTC1.internal.synopsys.com (10.12.238.230) with Microsoft SMTP Server (TLS) id 14.3.361.1; Sat, 5 May 2018 01:30:15 -0700 Received: from arturp-ubuntu (10.13.184.20) by us01wehtc1.internal.synopsys.com (10.12.239.236) with Microsoft SMTP Server (TLS) id 14.3.361.1; Sat, 5 May 2018 01:30:14 -0700 Received: by arturp-ubuntu (sSMTP sendmail emulation); Sat, 05 May 2018 04:30:16 -0400 Date: Sat, 5 May 2018 04:30:16 -0400 Message-ID: <9398128bddf097e069788aed8bb3d03d3332571a.1525508898.git.arturp@synopsys.com> From: Artur Petrosyan Subject: [PATCH] usb: dwc2: Fix crash in incomplete isoc intr handlers. To: Felipe Balbi , Greg Kroah-Hartman , Minas Harutyunyan , CC: John Youn , Artur Petrosyan 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 Crash caused by going out of "eps_out" array range. Iteration on "eps_out" changed to less than "num_of_eps". Signed-off-by: Artur Petrosyan Acked-by: Minas Harutyunyan --- drivers/usb/dwc2/gadget.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c index 6c32bf26e48e..010cfbca962a 100644 --- a/drivers/usb/dwc2/gadget.c +++ b/drivers/usb/dwc2/gadget.c @@ -3427,7 +3427,7 @@ static void dwc2_gadget_handle_incomplete_isoc_in(struct dwc2_hsotg *hsotg) daintmsk = dwc2_readl(hsotg->regs + DAINTMSK); - for (idx = 1; idx <= hsotg->num_of_eps; idx++) { + for (idx = 1; idx < hsotg->num_of_eps; idx++) { hs_ep = hsotg->eps_in[idx]; /* Proceed only unmasked ISOC EPs */ if (!hs_ep->isochronous || (BIT(idx) & ~daintmsk)) @@ -3473,7 +3473,7 @@ static void dwc2_gadget_handle_incomplete_isoc_out(struct dwc2_hsotg *hsotg) daintmsk = dwc2_readl(hsotg->regs + DAINTMSK); daintmsk >>= DAINT_OUTEP_SHIFT; - for (idx = 1; idx <= hsotg->num_of_eps; idx++) { + for (idx = 1; idx < hsotg->num_of_eps; idx++) { hs_ep = hsotg->eps_out[idx]; /* Proceed only unmasked ISOC EPs */ if (!hs_ep->isochronous || (BIT(idx) & ~daintmsk)) @@ -3647,7 +3647,7 @@ static irqreturn_t dwc2_hsotg_irq(int irq, void *pw) dwc2_writel(gintmsk, hsotg->regs + GINTMSK); dev_dbg(hsotg->dev, "GOUTNakEff triggered\n"); - for (idx = 1; idx <= hsotg->num_of_eps; idx++) { + for (idx = 1; idx < hsotg->num_of_eps; idx++) { hs_ep = hsotg->eps_out[idx]; /* Proceed only unmasked ISOC EPs */ if (!hs_ep->isochronous || (BIT(idx) & ~daintmsk))