Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp6772233pxv; Fri, 30 Jul 2021 01:52:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwvBqqezlAeoLV14Z6wK0zyLbqU6f/uoGh8EPQGC6gtEh3H/8umKV4f041QwsqTHJrUccCk X-Received: by 2002:a5d:8541:: with SMTP id b1mr109523ios.105.1627635154441; Fri, 30 Jul 2021 01:52:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627635154; cv=none; d=google.com; s=arc-20160816; b=Jdpon8GdCACjy9qx6TFMvdCzniyuFRoI2U0sSmKKU7HkIZERV545o7yCS+EEzaiGNE uLLZVzGkVaEa1bkmxGW07mclqWOgFWYhGntoVZsvjyrc45akQuC8ARgrTd+k7A+PRdpX 8AqAlneM8qHn5HR1uMXD6eILyOzRGShbw4LzmvmrGxYfaw04ATRQTee1TWlfrD51SggN M1vJ/OJlKFoyMZmaj4mVfX2omIJVY6lfNk/s2Kq6a8vj7dV29Rv0YrzQFMSIA+0r724x ezV4dDHRKrttXVHxx8hVs3wp4U6QKXxn9Zy4mHLOjh9MfwN8qCKekvEF7vOOW6ke+r6O Mq0w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from; bh=Waan7LPzbhipX48wA0NkDF4t+mR9IStySX1KacFltFs=; b=Y5rsAFo212MNF3+sBy1MjFC4wz2cq2xe+W36BIQ9KFOcXbAiRH3sb6DT9z8mDnYOMX ey4FUvcB5G2pdUFBjjo3kxwu1LVNHW37mURxOBzu70z+5Xja8adO0nxtGcFexr2r68Zf KaHBlNAYQKEKwiRPbDrFcgyiyKuGTdN6Pz9upBjsitWyxzBlF/Mfz2YoTaJFzfQ9I4Bz 5Gf1LTNzUqfM2GkFHlw2BD5j5yO4xJYYe+UyBvcLL3fwub2OAKBV5Cj9jF1VtDY1i91K xPanU3JgoSkU/J4m6bPUgLfp/HEK7woJxNBbYxRv4hJBKXW8m5vPoBHjpOBM882EFqOb WewQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d1si1131173jak.77.2021.07.30.01.52.23; Fri, 30 Jul 2021 01:52:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238230AbhG3IvL (ORCPT + 99 others); Fri, 30 Jul 2021 04:51:11 -0400 Received: from mailgw02.mediatek.com ([210.61.82.184]:36136 "EHLO mailgw02.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S238133AbhG3Iux (ORCPT ); Fri, 30 Jul 2021 04:50:53 -0400 X-UUID: b2f110478bec4adbba7b798366eb34e5-20210730 X-UUID: b2f110478bec4adbba7b798366eb34e5-20210730 Received: from mtkexhb01.mediatek.inc [(172.21.101.102)] by mailgw02.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 1464105308; Fri, 30 Jul 2021 16:50:45 +0800 Received: from mtkcas11.mediatek.inc (172.21.101.40) by mtkmbs06n1.mediatek.inc (172.21.101.129) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Fri, 30 Jul 2021 16:50:44 +0800 Received: from localhost.localdomain (10.17.3.153) by mtkcas11.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Fri, 30 Jul 2021 16:50:43 +0800 From: Chunfeng Yun To: Rob Herring , Mathias Nyman CC: Chunfeng Yun , Greg Kroah-Hartman , Matthias Brugger , , , , , , Eddie Hung Subject: [PATCH 09/11] usb: xhci-mtk: check boundary before check tt Date: Fri, 30 Jul 2021 16:50:00 +0800 Message-ID: <1627635002-24521-9-git-send-email-chunfeng.yun@mediatek.com> X-Mailer: git-send-email 1.8.1.1.dirty In-Reply-To: <1627635002-24521-1-git-send-email-chunfeng.yun@mediatek.com> References: <1627635002-24521-1-git-send-email-chunfeng.yun@mediatek.com> MIME-Version: 1.0 Content-Type: text/plain X-MTK: N Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org check_sch_tt() will access fs_bus_bw[] array, check boundary firstly to avoid out-of-bounds issue. Signed-off-by: Chunfeng Yun --- drivers/usb/host/xhci-mtk-sch.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/usb/host/xhci-mtk-sch.c b/drivers/usb/host/xhci-mtk-sch.c index 10c0f0f6461f..c2f13d69c607 100644 --- a/drivers/usb/host/xhci-mtk-sch.c +++ b/drivers/usb/host/xhci-mtk-sch.c @@ -600,13 +600,14 @@ static int check_sch_bw(struct mu3h_sch_bw_info *sch_bw, * and find a microframe where its worst bandwidth is minimum. */ for (offset = 0; offset < sch_ep->esit; offset++) { - ret = check_sch_tt(sch_ep, offset); - if (ret) - continue; if ((offset + sch_ep->num_budget_microframes) > esit_boundary) break; + ret = check_sch_tt(sch_ep, offset); + if (ret) + continue; + worst_bw = get_max_bw(sch_bw, sch_ep, offset); if (worst_bw > bw_boundary) continue; -- 2.18.0