Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp114979imm; Mon, 21 May 2018 03:15:23 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrWcuABLNkJdTY6Pzrd3Tfj6yI6wtFBUy9leErr3ZS/dqm5vz3GextrHQWU1kZskDlnpjnM X-Received: by 2002:a17:902:c6b:: with SMTP id 98-v6mr20316390pls.270.1526897723683; Mon, 21 May 2018 03:15:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526897723; cv=none; d=google.com; s=arc-20160816; b=kq4m7ySQP7YUV+8yz36ugpinaI+vSN58oIB4AQVrvzJisGF/89ea299oe016abzKzq r/2PEVlUuwqPc3vOK2srXr1VE9r0v/oZMxLXRT9nxll1uSCzBbJHRF3AlluAX3IsjVQ5 tpVlNs/yOhXnGrTKIXftReh7wTX1TsHNr5WdThDOG2Tm1+Qi/Lhd73L5y+DmFiJKJpbt Lvmyi1wiab/HOqPsIbYZNvSD1nm4abWlCyZd0nWoD3ilet5+QWHDpin14fvuOpWuJOsz ZioOOaXptCxEn3/gkYeD7jMXqoRCuv+eXnPukmWCycn0/TrfR4Gr95xKJ5YLxNIocitQ 0yPg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=mKTHeII7pdEsYS6zoAf7JVORIAY+sQgn/M+/yQYablU=; b=FUNkyQZhXFLdZcLuavfxTvL3Sk15pOZF9UkymjBnXN2iJtVUPTdeckbYzvKquFsjui RdOgJBEmw95MB9eksqx5iT3G2fhB3CT8toFYrOz/ck0j3Mvigw/ndo3XlMPerDaRT4st E3av/UQqW3QYOL2Aot9IQ78BkrY/DJBF+RLiULc9WgnIRRCHGCz2P17bm+W852N0ilyL EoMnuu2RP8Kzqu6P9NweTPcIK6aXGHJTMq5YglJl9XsfwxATu5bPN0B8BK2sq/QPFyhH HRU/n6BtC1iOYnNA188wbIYp/OZ5YGpWOcLuYR0X281rTUiqeZGd17TjjCe6M560W220 f7Rg== ARC-Authentication-Results: i=1; mx.google.com; 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 g63-v6si14187126pfd.93.2018.05.21.03.15.09; Mon, 21 May 2018 03:15:23 -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; 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 S1752044AbeEUKNV (ORCPT + 99 others); Mon, 21 May 2018 06:13:21 -0400 Received: from regular1.263xmail.com ([211.150.99.141]:52730 "EHLO regular1.263xmail.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751111AbeEUKNQ (ORCPT ); Mon, 21 May 2018 06:13:16 -0400 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 Cc: sergei.shtylyov@cogentembedded.com, heiko@sntech.de, linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, linux-rockchip@lists.infradead.org, frank.wang@rock-chips.com, huangtao@rock-chips.com, dianders@google.com, daniel.meng@rock-chips.com, John.Youn@synopsys.com, william.wu@rock-chips.com, fml@rock-chips.com 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 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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; } -- 2.0.0