From: sashiko-bot@kernel.org
To: "Svyatoslav Ryhel" <clamor95@gmail.com>
Cc: devicetree@vger.kernel.org, mfd@lists.linux.dev, robh@kernel.org,
conor+dt@kernel.org, lee@kernel.org
Subject: Re: [PATCH v2 2/3 RESEND] mfd: max8907: Remove platform_data based probing
Date: Wed, 14 Oct 2026 12:24:09 +0000 [thread overview]
Message-ID: <sashiko-outbox-171273@kernel.org> (raw)
In-Reply-To: <20261014121544.138958-3-clamor95@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] regulator: max8907: NULL pointer dereference if optional DT nodes are omitted
--
commit 71b1062244be38a96a85d244d04303ea12b325fe
Author: Svyatoslav Ryhel <clamor95@gmail.com>
mfd: max8907: Remove platform_data based probing
This patch removes legacy platform_data based probing for the max8907
driver, converting it to be strictly device tree based.
> diff --git a/drivers/regulator/max8907-regulator.c b/drivers/regulator/max8907-regulator.c
> index e59aa7a3ee546..907ed3fca5e97 100644
> --- a/drivers/regulator/max8907-regulator.c
> +++ b/drivers/regulator/max8907-regulator.c
[ ... ]
> @@ -312,10 +311,9 @@ static int max8907_regulator_probe(struct platform_device *pdev)
> struct regulator_dev *rdev;
>
> config.dev = pdev->dev.parent;
> - if (pdata)
> - idata = pdata->init_data[i];
> - else
> - idata = match_init_data(i);
> +
> + idata = match_init_data(i);
> +
[Severity: High]
Will this cause a NULL pointer dereference if optional regulator nodes are
omitted from the device tree?
Since the patch removes the platform_data fallback, the driver now relies
entirely on match_init_data(i). If a system omits the nodes for
MAX8907_BBAT, MAX8907_SDBY, or MAX8907_VRTC, match_init_data() will return
NULL.
Looking at max8907_regulator_probe() just below this change, idata is
unconditionally dereferenced for these specific regulators:
drivers/regulator/max8907-regulator.c:max8907_regulator_probe() {
...
switch (pmic->desc[i].id) {
...
case MAX8907_BBAT:
case MAX8907_SDBY:
case MAX8907_VRTC:
idata->supply_regulator = mbatt_rail_name;
break;
}
...
}
Could we add a NULL check for idata before dereferencing it here?
> config.init_data = idata;
> config.driver_data = pmic;
> config.regmap = max8907->regmap_gen;
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261014121544.138958-1-clamor95@gmail.com?part=2
next prev parent reply other threads:[~2026-10-14 12:24 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-14 12:15 [PATCH v2 0/3 RESEND] mfd: max8907: Schema, pdata and poweroff Svyatoslav Ryhel
2026-10-14 12:15 ` [PATCH v2 1/3 RESEND] regulator: dt-bindings: maxim,max8907: Convert to DT schema Svyatoslav Ryhel
2026-10-14 12:15 ` [PATCH v2 2/3 RESEND] mfd: max8907: Remove platform_data based probing Svyatoslav Ryhel
2026-10-14 12:24 ` sashiko-bot [this message]
2026-10-14 12:15 ` [PATCH v2 3/3 RESEND] mfd: max8907: Convert to use device managed poweroff handler Svyatoslav Ryhel
2026-10-14 12:25 ` 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=sashiko-outbox-171273@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=clamor95@gmail.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=lee@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