From: sashiko-bot@kernel.org
To: "Alexey Charkov" <alchark@flipper.net>
Cc: robh@kernel.org, devicetree@vger.kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH v2 3/5] power: reset: syscon-reboot-mode: enable supplies for the next stage
Date: Tue, 29 Sep 2026 10:39:01 +0000 [thread overview]
Message-ID: <20260929103901.E1A1B1F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260929-b4-rk3576-reboot-mode-v2-3-5a34ca72065a@flipper.net>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] power: reset: uninitialized pointer passed to regulator_bulk_enable()
--
commit cdeebbc0731de671c753a5b987cb44186458c7fb
Author: Alexey Charkov <alchark@flipper.net>
power: reset: syscon-reboot-mode: enable supplies for the next stage
This patch adds support for enabling power supplies named in the reboot mode
node when a boot mode is written. It requests the supplies in the probe
function using of_regulator_bulk_get_all() and enables them during reboot to
ensure the PMIC configuration is suitable for early boot code on the next
startup.
Link: https://lore.kernel.org/all/20260929-regulator-get-all-v1-1-e887c66a47f1@flipper.net/
> diff --git a/drivers/power/reset/syscon-reboot-mode.c b/drivers/power/reset/syscon-reboot-mode.c
> index e0772c9f70f7a..5ef882d818161 100644
> --- a/drivers/power/reset/syscon-reboot-mode.c
> +++ b/drivers/power/reset/syscon-reboot-mode.c
[ ... ]
> @@ -28,6 +32,20 @@ static int syscon_reboot_mode_write(struct reboot_mode_driver *reboot,
>
> syscon_rbm = container_of(reboot, struct syscon_reboot_mode, reboot);
>
> + /*
> + * Whatever acts on the mode (e.g. boot ROM) runs before the operating
> + * system, and may need supplies that the running system had powered
> + * down. Enable them here, and deliberately leave them enabled: the
> + * system is on its way down, and what runs next may not know how to
> + * turn them on.
> + */
> + if (syscon_rbm->num_supplies) {
> + ret = regulator_bulk_enable(syscon_rbm->num_supplies,
> + syscon_rbm->supplies);
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[Severity: High]
Does this code introduce a regression if regulator_bulk_enable() fails?
The commit message notes a separate fix for the core API issue where
of_regulator_bulk_get_all() leaves the supply names uninitialized. Because
of_regulator_bulk_get_all() uses kmalloc_objs() internally (which does not
zero memory), the 'supply' field in the returned array contains garbage
pointers:
drivers/regulator/of_regulator.c:of_regulator_bulk_get_all() {
...
_consumers = kmalloc_objs(struct regulator_bulk_data, num_consumers);
...
}
If regulator_bulk_enable() fails, the error path in the regulator core will
attempt to print the name of the failing supply:
drivers/regulator/core.c:regulator_bulk_enable() {
...
pr_err("Failed to enable %s: %pe\n", consumers[i].supply,
ERR_PTR(consumers[i].ret));
...
}
Because this patch relies on an uninitialized array from
of_regulator_bulk_get_all(), applying it independently introduces a regression
where the kernel will panic if a hardware issue or misconfiguration causes
regulator_bulk_enable() to fail during reboot.
> + if (ret < 0)
> + dev_err(reboot->dev, "enabling reboot mode supplies failed\n");
> + }
> +
> ret = regmap_update_bits(syscon_rbm->map, syscon_rbm->offset,
> syscon_rbm->mask, magic);
[ ... ]
> @@ -59,6 +85,21 @@ static int syscon_reboot_mode_probe(struct platform_device *pdev)
>
> of_property_read_u32(pdev->dev.of_node, "mask", &syscon_rbm->mask);
>
> + ret = of_regulator_bulk_get_all(&pdev->dev, pdev->dev.of_node,
> + &syscon_rbm->supplies);
> + if (ret < 0)
> + return dev_err_probe(&pdev->dev, ret,
> + "can't get reboot mode supplies\n");
> +
> + syscon_rbm->num_supplies = ret;
> + if (syscon_rbm->num_supplies) {
> + ret = devm_add_action_or_reset(&pdev->dev,
> + syscon_reboot_mode_put_supplies,
> + syscon_rbm);
> + if (ret)
> + return ret;
> + }
> +
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260929-b4-rk3576-reboot-mode-v2-0-5a34ca72065a@flipper.net?part=3
next prev parent reply other threads:[~2026-09-29 10:39 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-29 10:28 [PATCH v2 0/5] power: reset: syscon-reboot-mode: Add support for Rockchip RK3576 reboot modes Alexey Charkov
2026-09-29 10:28 ` [PATCH v2 1/5] dt-bindings: soc: rockchip: add boot ROM download boot mode Alexey Charkov
2026-09-30 11:45 ` Krzysztof Kozlowski
2026-09-30 13:56 ` Alexey Charkov
2026-10-06 15:09 ` Krzysztof Kozlowski
2026-09-29 10:28 ` [PATCH v2 2/5] dt-bindings: power: reset: syscon-reboot-mode: allow supplies Alexey Charkov
2026-09-30 11:47 ` Krzysztof Kozlowski
2026-09-30 11:50 ` Krzysztof Kozlowski
2026-09-30 11:58 ` Alexey Charkov
2026-09-29 10:28 ` [PATCH v2 3/5] power: reset: syscon-reboot-mode: enable supplies for the next stage Alexey Charkov
2026-09-29 10:39 ` sashiko-bot [this message]
2026-09-29 10:28 ` [PATCH v2 4/5] arm64: dts: rockchip: add reboot-mode node to RK3576 Alexey Charkov
2026-09-29 10:28 ` [PATCH v2 5/5] arm64: dts: rockchip: name the reboot mode supplies on RK3576 EVB1 Alexey Charkov
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=20260929103901.E1A1B1F000FF@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=alchark@flipper.net \
--cc=conor+dt@kernel.org \
--cc=devicetree@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