Linux LED subsystem development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Carlo Szelinsky" <github@szelinsky.de>
Cc: linux-leds@vger.kernel.org, lee@kernel.org
Subject: Re: [PATCH net-next v6 2/2] net: pse-pd: add LED trigger support via notification path
Date: Sun, 29 Nov 2026 12:15:58 +0000	[thread overview]
Message-ID: <sashiko-outbox-239581@kernel.org> (raw)
In-Reply-To: <20261128121525.3909836-3-github@szelinsky.de>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] net: pse-pd: uninitialized or stale admin_state_enabled in
  pse_pi_get_states()
--

commit 2a4f233cb7c3e4753e63b541d451694d1abc8a64
Author: Carlo Szelinsky <github@szelinsky.de>

net: pse-pd: add LED trigger support via notification path

This commit adds per-PI "delivering" and "enabled" LED triggers to the
PSE core and updates them on PI state changes and notification events.

> diff --git a/drivers/net/pse-pd/pse_core.c b/drivers/net/pse-pd/pse_core.c
> index 2fb10f5d8f8e1..0e8584567042b 100644
> --- a/drivers/net/pse-pd/pse_core.c
> +++ b/drivers/net/pse-pd/pse_core.c
[ ... ]
> +static int pse_pi_get_states(struct pse_controller_dev *pcdev, int id,
> +			     bool *delivering, bool *enabled)
> +{
[ ... ]
> +	/* Under software power control, the hardware is off until a PD
> +	 * is detected, so use the admin state the core keeps.
> +	 */
> +	if (pse_pw_d_is_sw_pw_control(pcdev, pcdev->pi[id].pw_d)) {
> +		*enabled = pcdev->pi[id].admin_state_enabled;
> +		return 0;
> +	}

[Severity: Medium]
Can pse_pi_get_states() read an uninitialized pcdev->pi[id].pw_d or a
stale pcdev->pi[id].admin_state_enabled under software power control?

In pse_controller_register(), pse_led_triggers_register() runs before
pse_register_pw_ds() populates pcdev->pi[id].pw_d.  If an LED with a
matching default_trigger activates during trigger registration,
pse_pw_d_is_sw_pw_control() sees pw_d == NULL and queries
ops->pi_get_admin_state() instead of admin_state_enabled.

Even after pse_register_pw_ds() runs, pcdev->pi[id].admin_state_enabled
remains zero-initialized until a consumer calls of_pse_control_get() ->
pse_control_get_internal(), which then initializes admin_state_enabled
without holding pcdev->lock or calling pse_led_update():

drivers/net/pse-pd/pse_core.c:pse_control_get_internal() {
    ...
	ret = pse_pi_is_hw_enabled(pcdev, index);
	if (ret < 0)
		goto put_module;

	pcdev->pi[index].admin_state_enabled = ret;
    ...
}

As a result, the "enabled" LED trigger can stay out of sync with the
actual admin state.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261128121525.3909836-1-github@szelinsky.de?part=2

  reply	other threads:[~2026-11-29 12:16 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-28 12:15 [PATCH net-next v6 0/2] net: pse-pd: add poll path and LED trigger support Carlo Szelinsky
2026-11-28 12:15 ` [PATCH net-next v6 1/2] net: pse-pd: add pse_poll_helper() Carlo Szelinsky
2026-11-28 12:15 ` [PATCH net-next v6 2/2] net: pse-pd: add LED trigger support via notification path Carlo Szelinsky
2026-11-29 12:15   ` sashiko-bot [this message]
2026-11-29 12:16 ` [PATCH net-next v6 0/2] net: pse-pd: add poll path and LED trigger support 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=sashiko-outbox-239581@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=github@szelinsky.de \
    --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