From: Zhiyong Tao <zhiyong.tao@mediatek.com>
To: <robh+dt@kernel.org>, <linus.walleij@linaro.org>,
<mark.rutland@arm.com>, <matthias.bgg@gmail.com>,
<sean.wang@kernel.org>
Cc: <srv_heupstream@mediatek.com>, <zhiyong.tao@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 <guodong.liu@mediatek.corp-partner.google.com>
Subject: [PATCH] pinctrl: mediatek: fix global-out-of-bounds issue
Date: Thu, 4 Nov 2021 09:40:39 +0800 [thread overview]
Message-ID: <20211104014039.26772-2-zhiyong.tao@mediatek.com> (raw)
In-Reply-To: <20211104014039.26772-1-zhiyong.tao@mediatek.com>
From: Guodong Liu <guodong.liu@mediatek.corp-partner.google.com>
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 <zhiyong.tao@mediatek.com>
Signed-off-by: Guodong Liu <guodong.liu@mediatek.corp-partner.google.com>
---
drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c b/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c
index 45ebdeba985a..9d57c897835c 100644
--- a/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c
+++ b/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c
@@ -286,7 +286,8 @@ static int mtk_xt_get_gpio_n(void *data, unsigned long eint_n,
*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)
+ if (((*gpio_chip)->ngpio > eint_n) &&
+ 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
next prev parent reply other threads:[~2021-11-04 1:40 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-04 1:40 [PATCH 0/1] Mediatek pinctrl patch Zhiyong Tao
2021-11-04 1:40 ` Zhiyong Tao [this message]
2021-11-04 6:07 ` [PATCH] pinctrl: mediatek: fix global-out-of-bounds issue Sean Wang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20211104014039.26772-2-zhiyong.tao@mediatek.com \
--to=zhiyong.tao@mediatek.com \
--cc=devicetree@vger.kernel.org \
--cc=guodong.liu@mediatek.corp-partner.google.com \
--cc=hui.liu@mediatek.com \
--cc=light.hsieh@mediatek.com \
--cc=linus.walleij@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=mark.rutland@arm.com \
--cc=matthias.bgg@gmail.com \
--cc=rex-bc.chen@mediatek.com \
--cc=robh+dt@kernel.org \
--cc=sean.wang@kernel.org \
--cc=sean.wang@mediatek.com \
--cc=seiya.wang@mediatek.com \
--cc=srv_heupstream@mediatek.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).