From: sashiko-bot@kernel.org
To: "Shivendra Pratap" <shivendra.pratap@oss.qualcomm.com>
Cc: krzk+dt@kernel.org, robh@kernel.org, conor+dt@kernel.org,
devicetree@vger.kernel.org
Subject: Re: [PATCH v22 03/13] power: reset: reboot-mode: Add support for predefined reboot modes
Date: Thu, 14 May 2026 21:09:13 +0000 [thread overview]
Message-ID: <20260514210914.42623C2BCB3@smtp.kernel.org> (raw)
In-Reply-To: <20260514-arm-psci-system_reset2-vendor-reboots-v22-3-28a5bde07483@oss.qualcomm.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] Memory allocated by reboot_mode_add_predefined_modes() leaks if driver probe fails before registration.
--
commit ee3620bd44dbaeea7086626f9b3f70bbf53b0350
Author: Shivendra Pratap <shivendra.pratap@oss.qualcomm.com>
power: reset: reboot-mode: Add support for predefined reboot modes
This commit extends the reboot-mode framework to handle predefined modes
alongside those defined in the device tree. Drivers can now define and
register their own reboot-modes via the framework using a centralized
initialization call.
> diff --git a/drivers/power/reset/reboot-mode.c b/drivers/power/reset/reboot-mode.c
> --- a/drivers/power/reset/reboot-mode.c
> +++ b/drivers/power/reset/reboot-mode.c
[ ... ]
> @@ -344,6 +375,55 @@ void devm_reboot_mode_unregister(struct device *dev,
> }
> EXPORT_SYMBOL_GPL(devm_reboot_mode_unregister);
>
> +/**
> + * reboot_mode_add_predefined_modes - Add predefined reboot modes
> + * @reboot: reboot mode driver
> + * @modes: array of predefined reboot mode entries
> + * @count: number of entries in @modes
> + *
> + * Add predefined reboot modes in a single call before registration.
[ ... ]
> +int reboot_mode_add_predefined_modes(struct reboot_mode_driver *reboot,
> + const struct reboot_mode_entry *modes,
> + size_t count)
> +{
> + struct mode_info *info;
> + int ret;
> + size_t i;
> +
> + if (reboot->reboot_notifier.notifier_call == reboot_mode_notify ||
> + !list_empty(&reboot->predefined_modes))
> + return -EBUSY;
> +
> + if (!modes || !count)
> + return -EINVAL;
> +
> + for (i = 0; i < count; i++) {
> + info = reboot_mode_create_info(modes[i].name, modes[i].magic);
> + if (IS_ERR(info)) {
> + ret = PTR_ERR(info);
> + goto error;
> + }
> +
> + list_add_tail(&info->list, &reboot->predefined_modes);
> + }
> +
> + return 0;
> +
> +error:
> + reboot_mode_release_list(&reboot->predefined_modes);
> + return ret;
> +}
> +EXPORT_SYMBOL_GPL(reboot_mode_add_predefined_modes);
If a driver successfully calls reboot_mode_add_predefined_modes(), but the
probe function fails before reboot_mode_register() is called, does this code
leak the dynamically allocated mode_info structures?
For example, if devm_reboot_mode_register() internally fails at
devres_alloc() and returns -ENOMEM before calling reboot_mode_register(),
the framework will not be registered. Since devres will later free the
reboot_mode_driver itself, the dynamically allocated list elements added to
predefined_modes appear to be permanently orphaned.
Would it be possible to provide an exported cleanup function for error
handling, or perhaps manage these allocations using devres?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260514-arm-psci-system_reset2-vendor-reboots-v22-0-28a5bde07483@oss.qualcomm.com?part=3
next prev parent reply other threads:[~2026-05-14 21:09 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-14 14:25 [PATCH v22 00/13] Implement PSCI reboot mode driver for PSCI resets Shivendra Pratap
2026-05-14 14:25 ` [PATCH v22 01/13] power: reset: reboot-mode: Remove devres based allocations Shivendra Pratap
2026-05-14 14:25 ` [PATCH v22 02/13] power: reset: reboot-mode: Add support for 64 bit magic Shivendra Pratap
2026-05-14 20:15 ` sashiko-bot
2026-05-14 14:25 ` [PATCH v22 03/13] power: reset: reboot-mode: Add support for predefined reboot modes Shivendra Pratap
2026-05-14 21:09 ` sashiko-bot [this message]
2026-05-14 14:25 ` [PATCH v22 04/13] firmware: psci: Introduce command-based resets Shivendra Pratap
2026-05-14 21:23 ` sashiko-bot
2026-05-14 14:25 ` [PATCH v22 05/13] mfd: psci-mfd: Add PSCI MFD driver for cpuidle-psci-domain cell Shivendra Pratap
2026-05-14 14:25 ` [PATCH v22 06/13] dt-bindings: arm: Document reboot mode magic Shivendra Pratap
2026-05-14 14:25 ` [PATCH v22 07/13] power: reset: Add psci-reboot-mode driver Shivendra Pratap
2026-05-14 22:49 ` sashiko-bot
2026-05-14 14:25 ` [PATCH v22 08/13] mfd: core: Add firmware-node support to MFD cells Shivendra Pratap
2026-05-14 23:19 ` sashiko-bot
2026-05-14 14:25 ` [PATCH v22 09/13] mfd: psci-mfd: Add psci-reboot-mode child cell Shivendra Pratap
2026-05-14 14:25 ` [PATCH v22 10/13] arm64: dts: qcom: Add psci reboot-modes for kodiak boards Shivendra Pratap
2026-05-14 14:25 ` [PATCH v22 11/13] arm64: dts: qcom: Add psci reboot-modes for lemans boards Shivendra Pratap
2026-05-14 14:25 ` [PATCH v22 12/13] arm64: dts: qcom: Add psci reboot-modes for monaco boards Shivendra Pratap
2026-05-15 0:24 ` sashiko-bot
2026-05-14 14:25 ` [PATCH v22 13/13] arm64: dts: qcom: Add psci reboot-modes for talos boards Shivendra Pratap
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=20260514210914.42623C2BCB3@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=krzk+dt@kernel.org \
--cc=robh@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=shivendra.pratap@oss.qualcomm.com \
/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