Linux LED subsystem development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Rong Zhang" <i@rong.moe>
Cc: linux-leds@vger.kernel.org, lee@kernel.org
Subject: Re: [PATCH v4 05/12] leds: turris-omnia: Implement offloaded() trigger callback and declare hw_control_trigger
Date: Sun, 02 Aug 2026 17:31:45 +0000	[thread overview]
Message-ID: <20260802173146.22AB71F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <20260802-leds-trigger-hw-changed-v4-5-f97e2ca976fe@rong.moe>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [High] Registering a globally shared static trigger via `devm_led_trigger_register()` corrupts internal trigger lists when multiple instances probe.
--

--- Patch [5]: [PATCH v4 05/12] leds: turris-omnia: Implement offloaded() trigger callback and declare hw_control_trigger ---
commit 258c3687f19ed5315a5258f70ed410cbdb5b243c
Author: Rong Zhang <i@rong.moe>

leds: turris-omnia: Implement offloaded() trigger callback and declare hw_control_trigger

The omnia-mcu trigger always stays in hardware control mode. This commit
implements the offloaded() callback to always return true and declares it
as a hardware control trigger.

> diff --git a/drivers/leds/leds-turris-omnia.c b/drivers/leds/leds-turris-omnia.c
> index ed6a47bbb44f9..32d40d176d3f1 100644
> --- a/drivers/leds/leds-turris-omnia.c
> +++ b/drivers/leds/leds-turris-omnia.c

[ ... ]

> @@ -195,10 +195,16 @@ static void omnia_hwtrig_deactivate(struct led_classdev *cdev)
>  			err);
>  }
>  
> +static bool omnia_hwtrig_offloaded(struct led_classdev *cdev)
> +{
> +	return true;
> +}
> +
>  static struct led_trigger omnia_hw_trigger = {
>  	.name		= "omnia-mcu",

[Severity: High]
This is a pre-existing issue, but could this statically allocated global
trigger lead to list corruption when multiple instances of the device probe?

If a second instance of the device is bound (e.g., via sysfs new_device or a
DT overlay), omnia_leds_probe() will call devm_led_trigger_register() again
on this same global omnia_hw_trigger structure.

In led_trigger_register(), the core unconditionally executes
INIT_LIST_HEAD(&trig->led_cdevs) and spin_lock_init(&trig->leddev_list_lock)
before checking for duplicate trigger names and returning -EEXIST.

Because the same global structure is passed, this resets the list head of the
first, active instance, stranding the currently attached LEDs.

Subsequent attempts to unregister the first device or trigger events will then
operate on a corrupted linked list, potentially causing a kernel oops.

>  	.activate	= omnia_hwtrig_activate,
>  	.deactivate	= omnia_hwtrig_deactivate,
> +	.offloaded	= omnia_hwtrig_offloaded,
>  	.trigger_type	= &omnia_hw_trigger_type,
>  };

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260802-leds-trigger-hw-changed-v4-0-f97e2ca976fe@rong.moe?part=5

  reply	other threads:[~2026-08-02 17:31 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-01 17:26 [PATCH v4 00/12] leds: Add support for hardware-initiated hardware control trigger transition Rong Zhang
2026-08-01 17:26 ` [PATCH v4 01/12] leds: Move led_trigger_is_hw_controlled() to the right place Rong Zhang
2026-08-02 17:31   ` sashiko-bot
2026-08-01 17:26 ` [PATCH v4 02/12] leds: class: Remove hardware control trigger when writing brightness Rong Zhang
2026-08-02 17:31   ` sashiko-bot
2026-08-01 17:26 ` [PATCH v4 03/12] leds: trigger: Add offloaded() callback and provide trigger_may_offload attribute Rong Zhang
2026-08-02 17:31   ` sashiko-bot
2026-08-01 17:26 ` [PATCH v4 04/12] leds: cros_ec: Implement offloaded() trigger callback Rong Zhang
2026-08-02 17:31   ` sashiko-bot
2026-08-01 17:26 ` [PATCH v4 05/12] leds: turris-omnia: Implement offloaded() trigger callback and declare hw_control_trigger Rong Zhang
2026-08-02 17:31   ` sashiko-bot [this message]
2026-08-01 17:26 ` [PATCH v4 06/12] leds: trigger: netdev: Implement offloaded() callback Rong Zhang
2026-08-02 17:31   ` sashiko-bot
2026-08-01 17:26 ` [PATCH v4 07/12] leds: trigger: Enforce strict checks in led_trigger_is_hw_controlled() Rong Zhang
2026-08-02 17:31   ` sashiko-bot
2026-08-01 17:26 ` [PATCH v4 08/12] leds: trigger: Do not attach trigger to a removing LED Rong Zhang
2026-08-02 17:31   ` sashiko-bot
2026-08-01 17:26 ` [PATCH v4 09/12] leds: trigger: Add led_trigger_notify_hw_control_changed() interface Rong Zhang
2026-08-02 17:31   ` sashiko-bot
2026-08-01 17:26 ` [PATCH v4 10/12] platform/x86: ideapad-laptop: Decouple hardware & classdev brightness for keyboard backlight Rong Zhang
2026-08-02 17:31   ` sashiko-bot
2026-08-01 17:26 ` [PATCH v4 11/12] platform/x86: ideapad-laptop: Serialize keyboard backlight notifications Rong Zhang
2026-08-02 17:31   ` sashiko-bot
2026-08-01 17:26 ` [PATCH v4 12/12] platform/x86: ideapad-laptop: Fully support auto keyboard backlight Rong Zhang
2026-08-02 17:31   ` 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=20260802173146.22AB71F00A3A@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=i@rong.moe \
    --cc=lee@kernel.org \
    --cc=linux-leds@vger.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