From: sashiko-bot@kernel.org
To: "Rong Zhang" <i@rong.moe>
Cc: linux-leds@vger.kernel.org, lee@kernel.org
Subject: Re: [PATCH v5 06/12] leds: trigger: netdev: Implement offloaded() callback
Date: Fri, 21 Aug 2026 17:27:33 +0000 [thread overview]
Message-ID: <20260821172734.2E4041F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260821-leds-trigger-hw-changed-v5-6-3e00d6c4a936@rong.moe>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
New issues:
- [Medium] Unprotected lockless read of shared state in `netdev_trig_offloaded()`
Pre-existing issues:
- [High] Resource leak of `net_device` in `netdev_trig_activate()` error path
--
--- Patch [6]: [PATCH v5 06/12] leds: trigger: netdev: Implement offloaded() callback ---
commit d8144f7505ed647e0e3c94f8c01b2ef2b0814005
Author: Rong Zhang <i@rong.moe>
leds: trigger: netdev: Implement offloaded() callback
This commit implements the offloaded callback for the netdev trigger,
providing its hardware control state to the LED core. It also updates the
sysfs ABI documentation to clarify the relationship between the custom and
generic offload attributes.
> 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;
[Severity: Medium]
Is it possible for hw_control to be read while it is being updated?
When userspace reads the trigger_may_offload sysfs attribute, it calls
netdev_trig_offloaded() holding only the led_cdev->trigger_lock, which is a
read lock.
Concurrently, a network event can invoke netdev_trig_notify() which
acquires trigger_data->lock and mutates trigger_data->hw_control.
Does this code need to hold trigger_data->lock or use the READ_ONCE() macro
to prevent a data race when reading trigger_data->hw_control here?
> +}
> +
> static struct led_trigger netdev_led_trigger = {
> .name = "netdev",
> .activate = netdev_trig_activate,
> .deactivate = netdev_trig_deactivate,
> + .offloaded = netdev_trig_offloaded,
> .groups = netdev_trig_groups,
> };
[Severity: High]
This is a pre-existing issue, but does netdev_trig_activate() leak a
net_device reference in its error path?
If hardware control is supported, set_device_name() is called, which
acquires a net device reference via dev_get_by_name() and saves it to
trigger_data->net_dev.
If the subsequent call to register_netdevice_notifier() fails, the error
path executes:
drivers/leds/trigger/ledtrig-netdev.c:netdev_trig_activate() {
...
rc = register_netdevice_notifier(&trigger_data->notifier);
if (rc)
kfree(trigger_data);
return rc;
}
Since trigger_data is freed without calling dev_put(trigger_data->net_dev),
does this leave a permanent reference count leak on the net_device?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260821-leds-trigger-hw-changed-v5-0-3e00d6c4a936@rong.moe?part=6
next prev parent reply other threads:[~2026-08-21 17:27 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-20 17:21 [PATCH v5 00/12] leds: Add support for hardware-initiated hardware control trigger transition Rong Zhang
2026-08-20 17:21 ` [PATCH v5 01/12] leds: Move led_trigger_is_hw_controlled() to the right place Rong Zhang
2026-08-21 17:27 ` sashiko-bot
2026-08-20 17:21 ` [PATCH v5 02/12] leds: class: Remove hardware control trigger when writing brightness Rong Zhang
2026-08-21 17:27 ` sashiko-bot
2026-08-20 17:21 ` [PATCH v5 03/12] leds: trigger: Add offloaded() callback and provide trigger_may_offload attribute Rong Zhang
2026-08-21 17:27 ` sashiko-bot
2026-08-20 17:21 ` [PATCH v5 04/12] leds: cros_ec: Implement offloaded() trigger callback Rong Zhang
2026-08-21 17:27 ` sashiko-bot
2026-08-20 17:22 ` [PATCH v5 05/12] leds: turris-omnia: Implement offloaded() trigger callback and declare hw_control_trigger Rong Zhang
2026-08-21 17:27 ` sashiko-bot
2026-08-22 18:56 ` Rong Zhang
2026-08-20 17:22 ` [PATCH v5 06/12] leds: trigger: netdev: Implement offloaded() callback Rong Zhang
2026-08-21 17:27 ` sashiko-bot [this message]
2026-08-22 19:01 ` Rong Zhang
2026-08-20 17:22 ` [PATCH v5 07/12] leds: trigger: Enforce strict checks in led_trigger_is_hw_controlled() Rong Zhang
2026-08-21 17:27 ` sashiko-bot
2026-08-22 19:10 ` Rong Zhang
2026-08-20 17:22 ` [PATCH v5 08/12] leds: trigger: Do not attach trigger to a removing LED Rong Zhang
2026-08-21 17:27 ` sashiko-bot
2026-08-22 19:40 ` Rong Zhang
2026-08-20 17:22 ` [PATCH v5 09/12] leds: trigger: Add led_trigger_notify_hw_control_changed() interface Rong Zhang
2026-08-21 17:27 ` sashiko-bot
2026-08-20 17:22 ` [PATCH v5 10/12] platform/x86: ideapad-laptop: Decouple hardware & classdev brightness for keyboard backlight Rong Zhang
2026-08-21 17:27 ` sashiko-bot
2026-08-22 20:26 ` Rong Zhang
2026-08-20 17:22 ` [PATCH v5 11/12] platform/x86: ideapad-laptop: Serialize keyboard backlight notifications Rong Zhang
2026-08-21 17:27 ` sashiko-bot
2026-08-20 17:22 ` [PATCH v5 12/12] platform/x86: ideapad-laptop: Fully support auto keyboard backlight Rong Zhang
2026-08-21 17:27 ` sashiko-bot
2026-08-22 20:25 ` Rong Zhang
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=20260821172734.2E4041F000E9@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