From: Shivendra Pratap <shivendra.pratap@oss.qualcomm.com>
To: sashiko-reviews@lists.linux.dev, Sebastian Reichel <sre@kernel.org>
Cc: conor+dt@kernel.org, lee@kernel.org, devicetree@vger.kernel.org,
robh@kernel.org, mfd@lists.linux.dev
Subject: Re: [PATCH v25 02/10] power: reset: reboot-mode: Add support for predefined reboot modes
Date: Tue, 15 Sep 2026 19:24:00 +0530 [thread overview]
Message-ID: <abc41d74-c267-42bb-8a29-513e4e54be7d@oss.qualcomm.com> (raw)
In-Reply-To: <20260914151237.911CA1F000FF@smtp.kernel.org>
On 9/14/2026 8:42 PM, sashiko-bot@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
> - [Medium] Predefined modes overlapping with DT-defined modes cause duplicate entries in the sysfs `reboot_modes` attribute.
> --
>
> commit 394fababa44a1d093815c91cc11774a6de1c1f6b
> Author: Shivendra Pratap <shivendra.pratap@oss.qualcomm.com>
>
> power: reset: reboot-mode: Add support for predefined reboot modes
>
> Extend the reboot-mode framework to support driver-defined predefined reboot
> modes. Add a centralized initcall to initialize driver state along with
> predefined modes.
>
>> diff --git a/drivers/power/reset/reboot-mode.c b/drivers/power/reset/reboot-mode.c
>> index 328fa37598df3..fd61de2263836 100644
>> --- a/drivers/power/reset/reboot-mode.c
>> +++ b/drivers/power/reset/reboot-mode.c
>
> [ ... ]
>
>> @@ -160,11 +234,38 @@ static int reboot_mode_create_device(struct reboot_mode_driver *reboot)
>> return 0;
>>
>> error:
>> - reboot_mode_release_list(priv);
>> + reboot_mode_release_list(&priv->head);
>> kfree(priv);
>> return ret;
>> }
>>
>> +static int reboot_mode_add_predefined_modes(struct reboot_mode_driver *reboot)
>> +{
>> + const struct reboot_mode_entry *modes = reboot->predefined_modes;
>> + struct mode_info *info;
>> + size_t i;
>> +
>> + if (!modes)
>> + return 0;
>> +
>> + for (i = 0; i < reboot->predefined_mode_count; i++) {
>> + if (modes[i].name && strpbrk(modes[i].name, "\n ,/"))
>> + return -EINVAL;
>> +
>> + if (!modes[i].count || modes[i].count > ARRAY_SIZE(modes[i].magic))
>> + return -EINVAL;
>> +
>> + info = reboot_mode_create_info(reboot->dev, modes[i].name,
>> + modes[i].magic, modes[i].count);
>> + if (IS_ERR(info))
>> + return PTR_ERR(info);
>> +
>> + list_add_tail(&info->list, &reboot->head);
>
> [Severity: Medium]
> Will this lead to duplicate string entries in the sysfs reboot_modes
> attribute?
>
> If a reboot mode provided by the Device Tree has the same name as one of the
> driver's predefined modes, reboot_mode_register() parses the DT property and
> adds it to the reboot->head list first.
>
> Immediately after, reboot_mode_add_predefined_modes() blindly appends the
> predefined mode to the same list here without checking if an entry with that
> name already exists.
>
> The duplicate entries are unconditionally propagated to the sysfs structure in
> reboot_mode_create_device(). This will cause reboot_modes_show() to print
> all modes sequentially, resulting in duplicate strings in sysfs when userspace
> reads the /sys/class/reboot-mode/.../reboot_modes file.
The reboot-mode header adds a note that DT-defined mode will take
precedence, if a duplicate mode-name is present in both "DT list" and
the "pre-defined list".
We can add a duplicate check here, but would like the view of other
reviewers on this.
thanks,
Shivendra
next prev parent reply other threads:[~2026-09-15 13:54 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-14 14:59 [PATCH v25 00/10] Implement PSCI reboot mode driver for PSCI resets Shivendra Pratap
2026-09-14 14:59 ` [PATCH v25 01/10] power: reset: reboot-mode: Support up to 3 magic values per mode Shivendra Pratap
2026-09-14 15:09 ` sashiko-bot
2026-09-14 14:59 ` [PATCH v25 02/10] power: reset: reboot-mode: Add support for predefined reboot modes Shivendra Pratap
2026-09-14 15:12 ` sashiko-bot
2026-09-15 13:54 ` Shivendra Pratap [this message]
2026-09-14 14:59 ` [PATCH v25 03/10] firmware: psci: Introduce command-based resets Shivendra Pratap
2026-09-14 15:14 ` sashiko-bot
2026-09-15 14:02 ` Shivendra Pratap
2026-09-15 14:05 ` Shivendra Pratap
2026-09-14 14:59 ` [PATCH v25 04/10] firmware: psci: Add support for PSCI auxiliary devices Shivendra Pratap
2026-09-14 15:21 ` sashiko-bot
2026-09-16 9:29 ` Bartosz Golaszewski
2026-09-17 12:18 ` Shivendra Pratap
2026-09-21 15:06 ` Ulf Hansson
2026-09-23 11:25 ` Shivendra Pratap
2026-09-14 14:59 ` [PATCH v25 05/10] dt-bindings: arm: Document reboot mode magic Shivendra Pratap
2026-09-14 15:19 ` sashiko-bot
2026-09-18 22:06 ` Rob Herring
2026-09-21 10:29 ` Shivendra Pratap
2026-09-21 18:41 ` Rob Herring
2026-09-14 14:59 ` [PATCH v25 06/10] power: reset: Add psci-reboot-mode driver Shivendra Pratap
2026-09-14 15:21 ` sashiko-bot
2026-09-16 9:23 ` Bartosz Golaszewski
2026-09-17 12:30 ` Shivendra Pratap
2026-09-14 14:59 ` [PATCH v25 07/10] arm64: dts: qcom: Add psci reboot-modes for kodiak boards Shivendra Pratap
2026-09-14 15:24 ` sashiko-bot
2026-09-14 14:59 ` [PATCH v25 08/10] arm64: dts: qcom: Add psci reboot-modes for lemans boards Shivendra Pratap
2026-09-14 15:28 ` sashiko-bot
2026-09-14 14:59 ` [PATCH v25 09/10] arm64: dts: qcom: Add psci reboot-modes for monaco boards Shivendra Pratap
2026-09-14 15:25 ` sashiko-bot
2026-09-14 14:59 ` [PATCH v25 10/10] arm64: dts: qcom: Add psci reboot-modes for talos boards Shivendra Pratap
2026-09-14 15:27 ` 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=abc41d74-c267-42bb-8a29-513e4e54be7d@oss.qualcomm.com \
--to=shivendra.pratap@oss.qualcomm.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 \
--cc=sre@kernel.org \
/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