Re: [PATCH v4 05/12] leds: turris-omnia: Implement offloaded() trigger callback and declare hw_control_trigger

[email protected] Sun, 02 Aug 2026 17:31:45 +0000
Newsgroups org.kernel.vger.linux-leds
Message-ID <[email protected]>
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() t=
rigger callback and declare hw_control_trigger ---
commit 258c3687f19ed5315a5258f70ed410cbdb5b243c
Author: Rong Zhang <[email protected]>

leds: turris-omnia: Implement offloaded() trigger callback and declare hw_c=
ontrol_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_clas=
sdev *cdev)
>  			err);
>  }
> =20
> +static bool omnia_hwtrig_offloaded(struct led_classdev *cdev)
> +{
> +	return true;
> +}
> +
>  static struct led_trigger omnia_hw_trigger =3D {
>  	.name		=3D "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 t=
he
first, active instance, stranding the currently attached LEDs.

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

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

--=20
Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20260802-leds-trigg=
[email protected]?part=3D5