From: sashiko-bot@kernel.org
To: "Roman Vivchar" <rva333@protonmail.com>
Cc: robh@kernel.org, devicetree@vger.kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH v2 3/3] soc: mediatek: pwrap: add mt6572 support
Date: Wed, 15 Jul 2026 12:47:15 +0000 [thread overview]
Message-ID: <20260715124715.9FD281F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260715-6572-pwrap-v2-3-bea1d801c81b@protonmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] Unconditional access to `wrp->slave->dew_regs` in `pwrap_common_init_reg_clock` for `PWRAP_MT6572` can lead to a NULL pointer dereference or unintended PMIC register writes.
--
--- Patch [3]: [PATCH v2 3/3] soc: mediatek: pwrap: add mt6572 support ---
commit cbf0689188d0318bc80532d5ebc3a4d9de137810
Author: Roman Vivchar <rva333@protonmail.com>
soc: mediatek: pwrap: add mt6572 support
This commit adds mt6572 registers and platform data for the pmic wrapper,
omitting registers not included in the mt2701 array. It reuses the mt2701
SoC-specific initialization function.
> diff --git a/drivers/soc/mediatek/mtk-pmic-wrap.c b/drivers/soc/mediatek/mtk-pmic-wrap.c
> index a4b10b0a97cbb..3f05fc724e15b 100644
> --- a/drivers/soc/mediatek/mtk-pmic-wrap.c
> +++ b/drivers/soc/mediatek/mtk-pmic-wrap.c
[ ... ]
> @@ -1733,6 +1734,11 @@ static void pwrap_init_chip_select_ext(struct pmic_wrapper *wrp, u8 hext_write,
> static int pwrap_common_init_reg_clock(struct pmic_wrapper *wrp)
> {
> switch (wrp->master->type) {
> + case PWRAP_MT6572:
> + pwrap_writel(wrp, 0x8, PWRAP_RDDMY);
> + pwrap_write(wrp, wrp->slave->dew_regs[PWRAP_DEW_RDDMY_NO], 0x8);
[Severity: Medium]
Could this unconditional access to wrp->slave->dew_regs cause a NULL pointer
dereference or unintended register writes if a malformed device tree is
provided?
If mediatek,mt6572-pwrap is paired with a PMIC that lacks dew_regs (such as
mediatek,mt6380-regulator) or lacks PWRAP_DEW_RDDMY_NO, pwrap_common_init_reg_clock
will blindly dereference the array.
Other cases in this switch block, such as PWRAP_MT6795, verify the slave type
before accessing dew_regs:
case PWRAP_MT6795:
if (wrp->slave->type == PMIC_MT6331) {
const u32 *dew_regs = wrp->slave->dew_regs;
pwrap_write(wrp, dew_regs[PWRAP_DEW_RDDMY_NO], 0x8);
...
Would it be safer to add a similar slave type validation here to ensure we fail
gracefully on misconfigured device trees?
> + pwrap_init_chip_select_ext(wrp, 5, 0, 0, 0);
> + break;
> case PWRAP_MT6795:
> if (wrp->slave->type == PMIC_MT6331) {
> const u32 *dew_regs = wrp->slave->dew_regs;
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260715-6572-pwrap-v2-0-bea1d801c81b@protonmail.com?part=3
next prev parent reply other threads:[~2026-07-15 12:47 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-15 12:26 [PATCH v2 0/3] soc: mediatek: pwrap: mt6572 support + log level fixes Roman Vivchar via B4 Relay
2026-07-15 12:26 ` [PATCH v2 1/3] dt-bindings: soc: mediatek: pwrap: add mt6572 Roman Vivchar via B4 Relay
2026-07-15 12:26 ` [PATCH v2 2/3] soc: mediatek: pwrap: use correct log level Roman Vivchar via B4 Relay
2026-07-15 12:36 ` sashiko-bot
2026-07-15 12:26 ` [PATCH v2 3/3] soc: mediatek: pwrap: add mt6572 support Roman Vivchar via B4 Relay
2026-07-15 12:47 ` sashiko-bot [this message]
2026-07-15 13:22 ` AngeloGioacchino Del Regno
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=20260715124715.9FD281F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=robh@kernel.org \
--cc=rva333@protonmail.com \
--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