Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp2455908pxt; Mon, 9 Aug 2021 00:33:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzf0XgjfBl4j8npB1+fz0GHrWQg1psq2GZQfrjBk4Uq9Rqi53HSaw5mmMIjPUJ+UFhiMlug X-Received: by 2002:a05:6638:f0e:: with SMTP id h14mr20255887jas.124.1628494439591; Mon, 09 Aug 2021 00:33:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628494439; cv=none; d=google.com; s=arc-20160816; b=MK/gZFvpIm9HgoUr2N2QB1nHCRNM+Jg16Zra5Mcq7knda9Q5bHMsdumXuoj0qaRWdy QJIu8Z2pGAEWjsM64bvm+Xr4TUDPtCT+nOKJxXFeCj1z5M/eO6aiPZLfod/QjLPpPdAx enNxjRqMjdkbvXoLDVnEbD61MBb/oAVe8gKWmdqtRChDEM0SwybpIYfJOpkzn25RWYIy JgdC8OBecpw3Pjuj4wW0TN98SrQZsEVaP8O2nvA7unv0m8Fm402o2E+RnAzhFo0n8Lha aBvYjIh9QEvdLIcb2kRYkw88PAO9Hl1mnREsKQy/N+C+HBe6ecwKW04fWsSp9H1xOas9 gPSA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=NVCCSnIXYykkg2R7yVA5Ld91gUKOn2zITwPVLJyBQvQ=; b=nq86NycBG5BQ+t5lw4pzAP+GZkGcZP4to4y/hK2J7x48fLTt+v7mPsdKb27oQYbJQn locEo8e73dwuwmcJEmwi9ifskItBen3eg7XbfWlAd0bzu10+jW+nNcQvp5IG9/qkYFLx 45eHR3PVywplSoBuMnO3U6UNwimJpN8PIdUOdcR+t9V+ryKVvOz9nISl6h9JVjInhP6R NeYIPw50NkItHYfy9/gc2O2F7IdrzKOfqu3oAFAPr6s01aNX7yWFdqG2dcTBsOBiuT5I Zt+fGHy8LtOcTyjLJz+kQs4UCplNlSgEOrZ3nigfCDh1W/FWygz1MEqIXb2dTOPpL8/S GWWA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=JJ0xgqBn; 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=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z12si8934334ilb.144.2021.08.09.00.33.48; Mon, 09 Aug 2021 00:33:59 -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; dkim=pass header.i=@chromium.org header.s=google header.b=JJ0xgqBn; 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=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233445AbhHIHdG (ORCPT + 99 others); Mon, 9 Aug 2021 03:33:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33598 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233335AbhHIHdE (ORCPT ); Mon, 9 Aug 2021 03:33:04 -0400 Received: from mail-pj1-x1035.google.com (mail-pj1-x1035.google.com [IPv6:2607:f8b0:4864:20::1035]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 38C8CC0613CF for ; Mon, 9 Aug 2021 00:32:43 -0700 (PDT) Received: by mail-pj1-x1035.google.com with SMTP id fa24-20020a17090af0d8b0290178bfa69d97so935408pjb.0 for ; Mon, 09 Aug 2021 00:32:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=NVCCSnIXYykkg2R7yVA5Ld91gUKOn2zITwPVLJyBQvQ=; b=JJ0xgqBnD9h/5UXKJJkdIH5qjmoVw6ZhAxv2ayd+S0yB+m/LShHqM8AynrVtiYUuPD alwnu+6AGSPiAaPuawgIIconPh0TGQkupInxxbQwuXXiLrMagcGMZJzAZPpnexiGg+6Q yKPYKw7FJTDbtEkvB2KSnDDzvYmbkM/E5jEWg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=NVCCSnIXYykkg2R7yVA5Ld91gUKOn2zITwPVLJyBQvQ=; b=tL5KPgUULJ7yrIrv2W/oRZTrffps+o6H0YSUVtb/CYrx7Tf3hNqIWehahi7usu0CwL FIA0WdOSFkMC94zxjTe0PlUpONg3og9OMlFzHRwVLmdV0ri8k1d5VYZSqAItxizm4qKq KaGNdxH9gZhVYYigkaxN4N0N3wD6kN8KEld4Ml+buInO9FMlbCjIef9BZjblBGTG2n0J pzA4dueKjeLswaWKoNW7kO1OhI7eccnoXPQ22UivrVlxKyvaUnpvIkLxpUNz4GZGlDE+ Z94GaMHQ2Dhg0NNxSX1OBpdkeLTsYcTvnzQhSztOmXOoExL+kOYY6wk10HC+u5hwGUAW NGNA== X-Gm-Message-State: AOAM531JyDESn8sBQu+sFa7rVli99U6cxdJZB6BuEXP6QfY7sMgJVMnB WebC9yUMpRzKBUU7EL20vlSrxxtJ67pMrx3Q+SC0IQ== X-Received: by 2002:a17:90b:102:: with SMTP id p2mr150614pjz.126.1628494362683; Mon, 09 Aug 2021 00:32:42 -0700 (PDT) MIME-Version: 1.0 References: <1627635002-24521-1-git-send-email-chunfeng.yun@mediatek.com> <1627635002-24521-9-git-send-email-chunfeng.yun@mediatek.com> In-Reply-To: <1627635002-24521-9-git-send-email-chunfeng.yun@mediatek.com> From: Ikjoon Jang Date: Mon, 9 Aug 2021 15:32:31 +0800 Message-ID: Subject: Re: [PATCH 09/11] usb: xhci-mtk: check boundary before check tt To: Chunfeng Yun Cc: Rob Herring , Mathias Nyman , Greg Kroah-Hartman , Matthias Brugger , linux-usb@vger.kernel.org, "moderated list:ARM/Mediatek SoC support" , "moderated list:ARM/Mediatek SoC support" , "open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS" , open list , Eddie Hung Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Chunfeng, On Fri, Jul 30, 2021 at 4:50 PM Chunfeng Yun wrote: > > 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; Instead of dropping it, I'm wondering if it should be checked against (offset & 63) == 0 when it's 64? > > + 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 >