From patchwork Mon May 21 10:12:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: William Wu X-Patchwork-Id: 10414537 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 AAAAC60365 for ; Mon, 21 May 2018 10:13:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 977B02022C for ; Mon, 21 May 2018 10:13:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8C3D0280B0; Mon, 21 May 2018 10:13:33 +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=-1.4 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, MAILING_LIST_MULTI, RCVD_IN_SORBS_WEB autolearn=no version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 273FD2022C for ; Mon, 21 May 2018 10:13:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=yF99OjWu7bYHVeb1QVJ7CZ06zbhxciko2jj9G+/Nw8Q=; b=KnP iSPRp0TsIyAFd4pq8nuqxBa7gjNnZ0DShQKXOrKo4zgxeK5gwE/PjVsHqfu/cEPNyS1g6DyM9zaB2 e/69Ruc8SeC67wJqR5mj2eihd5WVRjCat6x4rLGewlFd75TEn/kLCPxcjaL4x2X0vFsF4plsAWFzL duhrJLwu0pY84boA/ZI2HjvKT97/+j2fiXwA7lM5LWQG7uBwXf+4ZzQ3bBRCosj17gSJ/W+XIxWhC 0dt2UxWH6SbjPXWRl0+zlsUfX9rkIlFTzP+CB9xlh4H73+52CMmZQYe5q2dlJutUbPqQLBHNq0Hgv 5zNPB2/Sz/wuu1Ro7ltNYttKcMWayuw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fKhop-00066L-Hb; Mon, 21 May 2018 10:13:31 +0000 Received: from regular1.263xmail.com ([211.150.99.141]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fKhom-0005EY-B8 for linux-rockchip@lists.infradead.org; Mon, 21 May 2018 10:13:30 +0000 Received: from william.wu?rock-chips.com (unknown [192.168.167.12]) by regular1.263xmail.com (Postfix) with ESMTP id 8DA8876; Mon, 21 May 2018 18:13:09 +0800 (CST) X-263anti-spam: KSV:0; X-MAIL-GRAY: 0 X-MAIL-DELIVERY: 1 X-KSVirus-check: 0 X-ABS-CHECKED: 4 Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.263.net (Postfix) with ESMTPA id 6293F3B2; Mon, 21 May 2018 18:13:07 +0800 (CST) X-IP-DOMAINF: 1 X-RL-SENDER: william.wu@rock-chips.com X-FST-TO: hminas@synopsys.com X-SENDER-IP: 58.22.7.114 X-LOGIN-NAME: william.wu@rock-chips.com X-UNIQUE-TAG: X-ATTACHMENT-NUM: 0 X-SENDER: wulf@rock-chips.com X-DNS-TYPE: 0 Received: from localhost.localdomain (unknown [58.22.7.114]) by smtp.263.net (Postfix) whith ESMTP id 17597TSMF4Y; Mon, 21 May 2018 18:13:09 +0800 (CST) From: William Wu To: hminas@synopsys.com, felipe.balbi@linux.intel.com, gregkh@linuxfoundation.org Subject: [PATCH] usb: dwc2: fix the incorrect bitmaps for the ports of multi_tt hub Date: Mon, 21 May 2018 18:12:00 +0800 Message-Id: <1526897520-9340-1-git-send-email-william.wu@rock-chips.com> X-Mailer: git-send-email 2.0.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180521_031328_620391_80C83541 X-CRM114-Status: GOOD ( 13.37 ) X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: huangtao@rock-chips.com, heiko@sntech.de, sergei.shtylyov@cogentembedded.com, frank.wang@rock-chips.com, fml@rock-chips.com, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, dianders@google.com, linux-rockchip@lists.infradead.org, william.wu@rock-chips.com, John.Youn@synopsys.com, daniel.meng@rock-chips.com MIME-Version: 1.0 Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+patchwork-linux-rockchip=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP The dwc2_get_ls_map() use ttport to reference into the bitmap if we're on a multi_tt hub. But the bitmaps index from 0 to (hub->maxchild - 1), while the ttport index from 1 to hub->maxchild. This will cause invalid memory access when the number of ttport is hub->maxchild. Without this patch, I can easily meet a Kernel panic issue if connect a low-speed USB mouse with the max port of FE2.1 multi-tt hub (1a40:0201) on rk3288 platform. Signed-off-by: William Wu Reviewed-by: Douglas Anderson --- drivers/usb/dwc2/hcd_queue.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/usb/dwc2/hcd_queue.c b/drivers/usb/dwc2/hcd_queue.c index d7c3d6c..9c55d1a 100644 --- a/drivers/usb/dwc2/hcd_queue.c +++ b/drivers/usb/dwc2/hcd_queue.c @@ -383,7 +383,7 @@ static unsigned long *dwc2_get_ls_map(struct dwc2_hsotg *hsotg, /* Get the map and adjust if this is a multi_tt hub */ map = qh->dwc_tt->periodic_bitmaps; if (qh->dwc_tt->usb_tt->multi) - map += DWC2_ELEMENTS_PER_LS_BITMAP * qh->ttport; + map += DWC2_ELEMENTS_PER_LS_BITMAP * (qh->ttport - 1); return map; }