From: sashiko-bot@kernel.org
To: "Luca Leonardo Scorcia" <l.scorcia@gmail.com>
Cc: conor+dt@kernel.org, mfd@lists.linux.dev,
devicetree@vger.kernel.org, linux-input@vger.kernel.org,
robh@kernel.org, dmitry.torokhov@gmail.com, lee@kernel.org
Subject: Re: [PATCH v10 6/9] input: keyboard: mtk-pmic-keys: Add MT6392 support
Date: Wed, 02 Sep 2026 20:37:45 +0000 [thread overview]
Message-ID: <20260902203745.F05A21F00A3E@smtp.kernel.org> (raw)
In-Reply-To: <20260902193351.185771-7-l.scorcia@gmail.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
Pre-existing issues:
- [High] Array out-of-bounds read and write due to mismatched DT child node counting and iteration.
- [High] Incorrect macro MTK_PMIC_HOMEKEY_INDEX used for homekey reset mask in mt6357_regs configuration.
--
commit 93a2f6ac06eb96960eb8f140af657b42448c3d24
Author: Val Packett <val@packett.cool>
input: keyboard: mtk-pmic-keys: Add MT6392 support
Add support for the MT6392 PMIC to the keys driver.
> diff --git a/drivers/input/keyboard/mtk-pmic-keys.c b/drivers/input/keyboard/mtk-pmic-keys.c
> index c78d9f6d97c4f..d758c7743f6a1 100644
> --- a/drivers/input/keyboard/mtk-pmic-keys.c
> +++ b/drivers/input/keyboard/mtk-pmic-keys.c
[ ... ]
While reviewing this patch, I noticed two pre-existing issues in the same
file.
In mt6357_regs:
> MTK_PMIC_KEYS_REGS(MT6357_TOPSTATUS,
> 0x8, MT6357_PSC_TOP_INT_CON0, 0xa,
> MTK_PMIC_HOMEKEY_INDEX),
[Severity: High]
This is a pre-existing issue, but does this incorrectly use
MTK_PMIC_HOMEKEY_INDEX instead of the intended reset mask
MTK_PMIC_HOMEKEY_RST?
If MTK_PMIC_HOMEKEY_INDEX is used, it expands to 1 instead of the correct
bitmask. This causes mtk_pmic_keys_lp_reset_setup() to clear the wrong bit
in the MT6357_TOP_RST_MISC register and fail to configure the home key's
reset mask.
In mtk_pmic_keys_probe():
> keycount = of_get_available_child_count(node);
> if (keycount > MTK_PMIC_MAX_KEY_COUNT ||
> keycount > ARRAY_SIZE(irqnames)) {
> dev_err(keys->dev, "too many keys defined (%d)\n", keycount);
> return -EINVAL;
> }
>
> for_each_child_of_node_scoped(node, child) {
> keys->keys[index].regs = &mtk_pmic_regs->keys_regs[index];
>
> keys->keys[index].irq =
> platform_get_irq_byname(pdev, irqnames[index]);
[Severity: High]
This is a pre-existing issue, but can this lead to an out-of-bounds array
access if disabled nodes are present in the device tree?
The bounds check counts available children using
of_get_available_child_count(). However, the loop uses
for_each_child_of_node_scoped(), which iterates over all child nodes
regardless of their status.
If a device tree contains three or more child nodes, but some are disabled
such that the available count is 2 or fewer, the bounds check passes. The
loop then processes all nodes, causing the index variable to exceed
MTK_PMIC_MAX_KEY_COUNT and corrupt memory.
Could we change the loop to use for_each_available_child_of_node_scoped()
to match the bounds check?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260902193351.185771-1-l.scorcia@gmail.com?part=6
next prev parent reply other threads:[~2026-09-02 20:37 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-02 19:25 [PATCH v10 0/9] Add support for MT6392 PMIC Luca Leonardo Scorcia
2026-09-02 19:25 ` [PATCH v10 1/9] dt-bindings: mfd: mt6397: Add " Luca Leonardo Scorcia
2026-09-02 19:41 ` sashiko-bot
2026-09-03 8:24 ` Krzysztof Kozlowski
2026-09-02 19:25 ` [PATCH v10 2/9] dt-bindings: input: mtk-pmic-keys: Add MT6392 PMIC keys Luca Leonardo Scorcia
2026-09-02 19:50 ` sashiko-bot
2026-09-02 19:25 ` [PATCH v10 3/9] regulator: dt-bindings: Add MediaTek MT6392 PMIC Luca Leonardo Scorcia
2026-09-02 20:00 ` sashiko-bot
2026-09-02 19:25 ` [PATCH v10 4/9] mfd: mt6397: Use MFD_CELL_* to describe sub-devices Luca Leonardo Scorcia
2026-09-02 20:10 ` sashiko-bot
2026-09-02 19:25 ` [PATCH v10 5/9] mfd: mt6397: Add support for MT6392 PMIC Luca Leonardo Scorcia
2026-09-02 20:24 ` sashiko-bot
2026-09-02 19:25 ` [PATCH v10 6/9] input: keyboard: mtk-pmic-keys: Add MT6392 support Luca Leonardo Scorcia
2026-09-02 20:37 ` sashiko-bot [this message]
2026-09-02 19:25 ` [PATCH v10 7/9] pinctrl: mediatek: mt6397: Add MediaTek MT6392 Luca Leonardo Scorcia
2026-09-02 20:50 ` sashiko-bot
2026-09-02 19:25 ` [PATCH v10 8/9] regulator: Add MediaTek MT6392 regulator Luca Leonardo Scorcia
2026-09-02 20:58 ` sashiko-bot
2026-09-02 19:25 ` [PATCH v10 9/9] arm64: dts: mediatek: Add MediaTek MT6392 PMIC dtsi Luca Leonardo Scorcia
2026-09-02 21:05 ` sashiko-bot
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=20260902203745.F05A21F00A3E@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=dmitry.torokhov@gmail.com \
--cc=l.scorcia@gmail.com \
--cc=lee@kernel.org \
--cc=linux-input@vger.kernel.org \
--cc=mfd@lists.linux.dev \
--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