Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp6130324pxb; Mon, 8 Nov 2021 03:45:16 -0800 (PST) X-Google-Smtp-Source: ABdhPJyuBO1ZE+ZXsAZuUJPeZRVUaK2rtIkvZ9E8uY0GEcSRuxD53/B486leF97ezMVBxh4KSqdH X-Received: by 2002:a02:c559:: with SMTP id g25mr1768261jaj.123.1636371916109; Mon, 08 Nov 2021 03:45:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1636371916; cv=none; d=google.com; s=arc-20160816; b=TyVCf7OEut0lNtczz8F6AiIMSJpvj2m9xVXmiHWmsv+Q4EY16LXMh+8n5TTg8V/ubs DBbfG8HtDYG2oRWce9t4cJW/WGsh1pTAhhzJMZbu76Isxpq/daUuiy600tOYtyOBDlDn IoZPGoCRIJdDZTAGosk0PiSff58lwDJtaGXtYrt2Ke1FzzUQZvCs9UJkNSDOhCEUEjph P6oY/TMMotLMIXNlkl+oR7koNkwrS29TpytQ7CKoUe/OfLAVE2tHad/3Mps5vPwGDZQw PQAQb+iPVR9OuohffXKWUa5Aiv3O6LtI7kdTivyQeNh6jkHjVM5DIW4AJfVBj48JgHk3 /NZQ== 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=eXgMKC9k7dVBPc7GXJ0i9A3v0PLbEQVurYRUswXeJ14=; b=iuXadWKscGnbnUwxkpMQOe6lc5Wl1AEWUicnJWQVivY2bNHf/AejDC28hRLPzxgtX4 oEzOr4rdxpqb/xeW3R01mUzCefwLI9mnZvUkAjkf4J9CnWPg+UwO5CHuawx/r+rnapaw p1GvIYct4aE7IuTtI6wgJPw6VCiAQBTWxcJ6Ah8pk7SkPM2lNBtYnZQY64vcFqSIcgBs nO74Pl7sXgA8KKX5kWzeXmmPnFAkhp2EHVfiUa68u6PbI+dBNOOY0vy93MsdsaJz/z+M KNrEuwvC1qGNqKRMo17t8BzIemh4hRCr49j+AjMjbKwh9C3F6Xl5Ttvt9Zc3eGCI1NIT RuNA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=GMUrD9cF; 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 x15si24034397ilu.173.2021.11.08.03.45.03; Mon, 08 Nov 2021 03:45:16 -0800 (PST) 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=GMUrD9cF; 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 S237738AbhKHIf4 (ORCPT + 99 others); Mon, 8 Nov 2021 03:35:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44208 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237001AbhKHIfz (ORCPT ); Mon, 8 Nov 2021 03:35:55 -0500 Received: from mail-ua1-x92d.google.com (mail-ua1-x92d.google.com [IPv6:2607:f8b0:4864:20::92d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 67DD7C061570 for ; Mon, 8 Nov 2021 00:33:11 -0800 (PST) Received: by mail-ua1-x92d.google.com with SMTP id s13so14374075uaj.11 for ; Mon, 08 Nov 2021 00:33:11 -0800 (PST) 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=eXgMKC9k7dVBPc7GXJ0i9A3v0PLbEQVurYRUswXeJ14=; b=GMUrD9cF4ys0Ne5QeiY1boHEUmgLrJKogjRUJYv+JOiOlCLwsHPpus6RLIpS1aTKEc b9ZmfolezMysdzYltsRvw38VDRkFvWSASXeRyimw2zzvCQX6337hJfcOxyKjscOpct5F NZItoB+PrucYaFhbhqzaHmjIndbDJdCCLj4j4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=eXgMKC9k7dVBPc7GXJ0i9A3v0PLbEQVurYRUswXeJ14=; b=m7kLev5hI2qAnSY+JFhdEZh4OhblTs8OpyNbqmV2q+tVSPSDFeqYV2E3uXh/KbEZeQ /bYHuCleLMXXBoiNnevWe+LYX2AuCStD57LOgX9Cpqc3xeRqhCxgm/iMzVjcaK0slQFe 7nLk6XAMw1QLFD0kwmw98cexV0LsZPZiwhtgr0rP6kYp8/Vv8tjdf9Ry/h2kR1Dnq3UV USODOiQizXtvKXmzAAQu3GHfaOg4iimEDUWSxqFlhSQab4Rqu7MYn0/hWxTeKxJpenou +jRdJAD5ZmI9cXv78fS9Y0QbTQIT3TLiFPkuPp6ha02ttpYOzCIoLtx14YJGfLtYoI/M 2KuA== X-Gm-Message-State: AOAM530C0AWSeWUY7K9/pWKtxURK8QYhYy9XHxL2d3b+By7S+MSpRZlv W9BmUko8MnrZWhIIIxMK//2plElLy9iOfmzPoXXaig== X-Received: by 2002:a67:ae47:: with SMTP id u7mr101092748vsh.7.1636360390609; Mon, 08 Nov 2021 00:33:10 -0800 (PST) MIME-Version: 1.0 References: <20211104112329.8446-1-zhiyong.tao@mediatek.com> <20211104112329.8446-2-zhiyong.tao@mediatek.com> In-Reply-To: <20211104112329.8446-2-zhiyong.tao@mediatek.com> From: Chen-Yu Tsai Date: Mon, 8 Nov 2021 16:32:59 +0800 Message-ID: Subject: Re: [PATCH v1] pinctrl: mediatek: fix global-out-of-bounds issue To: Zhiyong Tao Cc: robh+dt@kernel.org, linus.walleij@linaro.org, mark.rutland@arm.com, matthias.bgg@gmail.com, sean.wang@kernel.org, srv_heupstream@mediatek.com, hui.liu@mediatek.com, light.hsieh@mediatek.com, sean.wang@mediatek.com, seiya.wang@mediatek.com, rex-bc.chen@mediatek.com, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-gpio@vger.kernel.org, Guodong Liu Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Nov 4, 2021 at 7:24 PM Zhiyong Tao wrote: This should be tagged as v2. Your first submission, not tagged with any version or RFC/RFT, is v1. > When eint virtual eint number is greater than gpio number, > it maybe produce 'desc[eint_n]' size globle-out-of-bounds issue. > > Signed-off-by: Zhiyong Tao > Signed-off-by: Guodong Liu Guodong's Signed-off-by here is confusing, as they are not the author nor the submitter, and as far as the mailing list is concerned they have not handled this patch either. Looks like the original patch is from https://crrev.com/c/3233623 ? It's customary to preserve the authorship and append your Signed-off-by when submitting patches written by others. > --- > drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c | 8 ++++++-- > 1 file changed, 6 insertions(+), 2 deletions(-) > > diff --git a/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c b/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c > index 45ebdeba985a..12163d3c4bcb 100644 > --- a/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c > +++ b/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c > @@ -285,8 +285,12 @@ static int mtk_xt_get_gpio_n(void *data, unsigned long eint_n, > desc = (const struct mtk_pin_desc *)hw->soc->pins; > *gpio_chip = &hw->chip; > > - /* Be greedy to guess first gpio_n is equal to eint_n */ > - if (desc[eint_n].eint.eint_n == eint_n) > + /* > + * Be greedy to guess first gpio_n is equal to eint_n. > + * Only eint virtual eint number is greater than gpio number. > + */ > + if (hw->soc->npins > eint_n && Nit: I believe it's more common to have the variable on the left, and the invariable on the right, but maybe it's just me: if (eint_n < hw->soc->npins && ... Either way is OK I guess. ChenYu > + desc[eint_n].eint.eint_n == eint_n) > *gpio_n = eint_n; > else > *gpio_n = mtk_xt_find_eint_num(hw, eint_n); > -- > 2.25.1 > > > _______________________________________________ > Linux-mediatek mailing list > Linux-mediatek@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/linux-mediatek