From: sashiko-bot@kernel.org
To: "Alexander Letuchiy" <asalde.le1@gmail.com>
Cc: linux-gpio@vger.kernel.org, devicetree@vger.kernel.org,
robh@kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH 2/2] pinctrl: mediatek: Add support for MT6895 pinctrl
Date: Sun, 08 Nov 2026 18:39:13 +0000 [thread overview]
Message-ID: <sashiko-outbox-203909@kernel.org> (raw)
In-Reply-To: <20261108-pinctrl-mt6895-v1-2-f704c443b31a@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] pinctrl: mediatek: mt6895: out-of-bounds read of
mt6895_pull_type[]
--
commit 60c606b2dae303929573f6abbd4f0ebf7a610aff
Author: Alexander Letuchiy <asalde.le1@gmail.com>
pinctrl: mediatek: Add support for MT6895 pinctrl
This commit adds a Paris-based pinctrl and EINT driver for the MediaTek
MT6895 SoC, defining 227 physical GPIOs and 20 virtual EINT lines.
> diff --git a/drivers/pinctrl/mediatek/pinctrl-mt6895.c b/drivers/pinctrl/mediatek/pinctrl-mt6895.c
> new file mode 100644
> index 0000000000000..1eb8792912301
> --- /dev/null
> +++ b/drivers/pinctrl/mediatek/pinctrl-mt6895.c
[ ... ]
> +static const unsigned int mt6895_pull_type[] = {
> + MTK_PULL_PU_PD_TYPE, /* 0 */
> + MTK_PULL_PU_PD_TYPE, /* 1 */
[ ... ]
> + MTK_PULL_PU_PD_RSEL_TYPE, /* 225 */
> + MTK_PULL_PU_PD_RSEL_TYPE, /* 226 */
> +};
> +
> +static const char *const mt6895_pinctrl_register_base_names[] = {
> + "base", "rm", "rt", "rmm", "bl", "bm", "br",
> + "brr", "lb", "lm", "rtt", "tr", "tl", "lt",
> +};
> +
> +static const struct mtk_eint_hw mt6895_eint_hw = {
> + .port_mask = 0xf,
> + .ports = 3,
> + .ap_num = 247,
> + .db_cnt = 32,
> + .db_time = debounce_time_mt6878,
> +};
> +
> +static const struct mtk_pin_reg_calc mt6895_reg_cals[PINCTRL_PIN_REG_MAX] = {
> + [PINCTRL_PIN_REG_MODE] = MTK_RANGE(mt6895_pin_mode_range),
> + [PINCTRL_PIN_REG_DIR] = MTK_RANGE(mt6895_pin_dir_range),
> + [PINCTRL_PIN_REG_DI] = MTK_RANGE(mt6895_pin_di_range),
> + [PINCTRL_PIN_REG_DO] = MTK_RANGE(mt6895_pin_do_range),
> + [PINCTRL_PIN_REG_SMT] = MTK_RANGE(mt6895_pin_smt_range),
> + [PINCTRL_PIN_REG_IES] = MTK_RANGE(mt6895_pin_ies_range),
> + [PINCTRL_PIN_REG_PU] = MTK_RANGE(mt6895_pin_pu_range),
> + [PINCTRL_PIN_REG_PD] = MTK_RANGE(mt6895_pin_pd_range),
> + [PINCTRL_PIN_REG_DRV] = MTK_RANGE(mt6895_pin_drv_range),
> + [PINCTRL_PIN_REG_PUPD] = MTK_RANGE(mt6895_pin_pupd_range),
> + [PINCTRL_PIN_REG_R0] = MTK_RANGE(mt6895_pin_r0_range),
> + [PINCTRL_PIN_REG_R1] = MTK_RANGE(mt6895_pin_r1_range),
> + [PINCTRL_PIN_REG_DRV_ADV] = MTK_RANGE(mt6895_pin_adv_range),
> + [PINCTRL_PIN_REG_RSEL] = MTK_RANGE(mt6895_pin_rsel_range),
> +};
> +
> +static const struct mtk_pin_soc mt6895_data = {
> + .reg_cal = mt6895_reg_cals,
> + .pins = mtk_pins_mt6895,
> + .npins = ARRAY_SIZE(mtk_pins_mt6895),
> + .ngrps = ARRAY_SIZE(mtk_pins_mt6895),
> + .eint_hw = &mt6895_eint_hw,
> + .eint_pin = eint_pins_mt6895,
> + .nfuncs = 8,
> + .gpio_m = 0,
> + .base_names = mt6895_pinctrl_register_base_names,
> + .nbase_names = ARRAY_SIZE(mt6895_pinctrl_register_base_names),
> + .pull_type = mt6895_pull_type,
> + .bias_set_combo = mtk_pinconf_bias_set_combo,
> + .bias_get_combo = mtk_pinconf_bias_get_combo,
[Severity: Medium]
Can mtk_pinconf_bias_get_combo() and mtk_pinconf_bias_set_combo() read
past the end of mt6895_pull_type[]?
mtk_pins_mt6895[] has 247 entries including virtual EINT pins 227..246,
while mt6895_pull_type[] only has 227 entries for pins 0..226. Reading
debugfs pinconf-pins (which queries all 0..npins-1 pins) calls
mtk_pinconf_get() -> mtk_pinconf_bias_get_combo(), indexing
hw->soc->pull_type[desc->number] out of bounds for pins 227..246.
Adding 20 trailing zero entries to mt6895_pull_type[] for the virtual EINT
pins (as done in mt6735_pull_type[]) would avoid the out-of-bounds read.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261108-pinctrl-mt6895-v1-0-f704c443b31a@gmail.com?part=2
next prev parent reply other threads:[~2026-11-08 18:39 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-08 18:27 [PATCH 0/2] pinctrl: mediatek: Add MT6895 support Alexander Letuchiy
2026-11-08 18:27 ` [PATCH 1/2] dt-bindings: pinctrl: mediatek: Document MT6895 pin controller Alexander Letuchiy
2026-11-08 18:27 ` [PATCH 2/2] pinctrl: mediatek: Add support for MT6895 pinctrl Alexander Letuchiy
2026-11-08 18:39 ` sashiko-bot [this message]
2026-11-08 19:25 ` Alexander Letuchiy
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=sashiko-outbox-203909@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=asalde.le1@gmail.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=linux-gpio@vger.kernel.org \
--cc=robh@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/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