Linux LED subsystem development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Rong Zhang" <i@rong.moe>
Cc: lee@kernel.org, linux-leds@vger.kernel.org
Subject: Re: [PATCH RFC v3 06/11] leds: trigger: netdev: Implement offloaded() callback
Date: Sun, 19 Jul 2026 17:13:03 +0000	[thread overview]
Message-ID: <20260719171303.EF9521F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <20260719-leds-trigger-hw-changed-v3-6-5fb55722e36e@rong.moe>

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

Pre-existing issues:
- [High] Missing dev_put() on net_device when register_netdevice_notifier() fails in netdev_trig_activate().
- [High] sysfs store functions modify shared trigger state and call set_baseline_state() without locking, racing with network notifiers.
--

--- Patch [6]: [PATCH RFC v3 06/11] leds: trigger: netdev: Implement offloaded() callback ---
commit 0713a09815032fb80c29f765ff7ef7a8acfbd3d3
Author: Rong Zhang <i@rong.moe>

leds: trigger: netdev: Implement offloaded() callback

This patch adds an offloaded() callback to the netdev LED trigger to
provide its hardware control state to the LED core. It also updates the
documentation to clarify the relationship between the custom offloaded
attribute and the generic trigger_may_offload attribute.

> diff --git a/drivers/leds/trigger/ledtrig-netdev.c b/drivers/leds/trigger/ledtrig-netdev.c
> index 64c078e997f28..a26109ca4b1c9 100644
> --- a/drivers/leds/trigger/ledtrig-netdev.c
> +++ b/drivers/leds/trigger/ledtrig-netdev.c

[ ... ]

> @@ -754,10 +754,18 @@ static void netdev_trig_deactivate(struct led_classdev *led_cdev)
>  	kfree(trigger_data);
>  }
>  
> +static bool netdev_trig_offloaded(struct led_classdev *led_cdev)
> +{
> +	struct led_netdev_data *trigger_data = led_get_trigger_data(led_cdev);
> +
> +	return trigger_data->hw_control;
> +}
> +
>  static struct led_trigger netdev_led_trigger = {
>  	.name = "netdev",
>  	.activate = netdev_trig_activate,

[Severity: High]
This isn't a bug introduced by this patch, but I noticed a missing dev_put()
in the error path of netdev_trig_activate(). If register_netdevice_notifier()
fails, trigger_data is freed but the net_dev reference is leaked:

drivers/leds/trigger/ledtrig-netdev.c:netdev_trig_activate() {
    ...
    rc = register_netdevice_notifier(&trigger_data->notifier);
    if (rc)
        kfree(trigger_data);
    ...
}

Will this permanently leak the network device reference and cause
unregister_netdev() to hang indefinitely?

>  	.deactivate = netdev_trig_deactivate,
> +	.offloaded = netdev_trig_offloaded,
>  	.groups = netdev_trig_groups,

[Severity: High]
This is a pre-existing issue, but while reviewing the netdev trigger groups,
I noticed that the sysfs store functions modify shared state without locking:

drivers/leds/trigger/ledtrig-netdev.c:netdev_led_attr_store() {
    ...
    trigger_data->mode = mode;
    trigger_data->hw_control = can_hw_control(trigger_data);
    ...
    set_baseline_state(trigger_data);
    ...
}

drivers/leds/trigger/ledtrig-netdev.c:interval_store() {
    ...
    atomic_set(&trigger_data->interval, msecs_to_jiffies(value));
    set_baseline_state(trigger_data);
    ...
}

Could concurrent sysfs writes overwrite each other's state or race with
asynchronous network events handled by netdev_trig_notify(), leading to data
races on LED hardware control and timer schedules?

>  };

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260719-leds-trigger-hw-changed-v3-0-5fb55722e36e@rong.moe?part=6

  reply	other threads:[~2026-07-19 17:13 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-18 17:05 [PATCH RFC v3 00/11] leds: Add support for hardware-initiated hardware control trigger transition Rong Zhang
2026-07-18 17:05 ` [PATCH RFC v3 01/11] leds: Move led_trigger_is_hw_controlled() to the right place Rong Zhang
2026-07-19 17:13   ` sashiko-bot
2026-07-18 17:05 ` [PATCH RFC v3 02/11] leds: class: Remove hardware control trigger when writing brightness Rong Zhang
2026-07-19 17:13   ` sashiko-bot
2026-07-18 17:05 ` [PATCH RFC v3 03/11] leds: trigger: Add offloaded() callback and provide trigger_may_offload attribute Rong Zhang
2026-07-19 17:13   ` sashiko-bot
2026-07-18 17:05 ` [PATCH RFC v3 04/11] leds: cros_ec: trigger: Implement offloaded() callback Rong Zhang
2026-07-19 17:13   ` sashiko-bot
2026-07-18 17:05 ` [PATCH RFC v3 05/11] leds: turris-omnia: trigger: Implement offloaded() and declare hw_control_trigger Rong Zhang
2026-07-19 17:13   ` sashiko-bot
2026-07-18 17:05 ` [PATCH RFC v3 06/11] leds: trigger: netdev: Implement offloaded() callback Rong Zhang
2026-07-19 17:13   ` sashiko-bot [this message]
2026-07-18 17:05 ` [PATCH RFC v3 07/11] leds: trigger: Enforce strict checks in led_trigger_is_hw_controlled() Rong Zhang
2026-07-19 17:13   ` sashiko-bot
2026-07-18 17:05 ` [PATCH RFC v3 08/11] leds: trigger: Add led_trigger_notify_hw_control_changed() interface Rong Zhang
2026-07-19 17:13   ` sashiko-bot
2026-07-18 17:05 ` [PATCH RFC v3 09/11] platform/x86: ideapad-laptop: Decouple hardware & classdev brightness for keyboard backlight Rong Zhang
2026-07-19 17:13   ` sashiko-bot
2026-07-18 17:05 ` [PATCH RFC v3 10/11] platform/x86: ideapad-laptop: Serialize keyboard backlight notifications Rong Zhang
2026-07-19 17:13   ` sashiko-bot
2026-07-18 17:05 ` [PATCH RFC v3 11/11] platform/x86: ideapad-laptop: Fully support auto keyboard backlight Rong Zhang
2026-07-19 17:13   ` 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=20260719171303.EF9521F00A3A@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