From: sashiko-bot@kernel.org
To: "Sasha Levin" <sashal@kernel.org>
Cc: lee@kernel.org, linux-leds@vger.kernel.org
Subject: Re: [PATCH AUTOSEL 6.18-6.12] leds: trigger: gpio: Use GPIOD_FLAGS_BIT_NONEXCLUSIVE
Date: Mon, 31 Aug 2026 15:49:35 +0000 [thread overview]
Message-ID: <20260831154936.4EFF21F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260831133314.4125787-347-sashal@kernel.org>
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
- [High] Using GPIOD_FLAGS_BIT_NONEXCLUSIVE causes premature hardware un-configuration and refcount underflow when the shared GPIO is released, breaking the primary owner.
- [High] The patch fails to achieve its stated goal (supporting SFP shared GPIOs) because the SFP driver does not share IRQs, causing activation to always fail with -EBUSY.
- [Medium] The LED trigger driver blindly overwrites the shared GPIO's consumer name, erasing the primary driver's label.
--
commit 02d3bd93d29878c57dc994ff5d3e680adeef7f2e
Author: Piotr Kubik <piotr@kubik.pl>
Subject: leds: trigger: gpio: Use GPIOD_FLAGS_BIT_NONEXCLUSIVE
This commit adds the GPIOD_FLAGS_BIT_NONEXCLUSIVE flag when requesting
the GPIO in the LED trigger driver. This is intended to allow the trigger
to share a GPIO with another driver, such as an SFP module.
Link: https://patch.msgid.link/20260408115106.379834-1-piotr@kubik.pl
> diff --git a/drivers/leds/trigger/ledtrig-gpio.c b/drivers/leds/trigger/ledtrig-gpio.c
> index 7f6a2352b0acd..3199275fd250b 100644
> --- a/drivers/leds/trigger/ledtrig-gpio.c
> +++ b/drivers/leds/trigger/ledtrig-gpio.c
> @@ -86,7 +86,8 @@ static int gpio_trig_activate(struct led_classdev *led)
> * The generic property "trigger-sources" is followed,
> * and we hope that this is a GPIO.
> */
> - gpio_data->gpiod = gpiod_get_optional(dev, "trigger-sources", GPIOD_IN);
> + gpio_data->gpiod = gpiod_get_optional(dev, "trigger-sources",
> + GPIOD_IN | GPIOD_FLAGS_BIT_NONEXCLUSIVE);
[Severity: High]
Does acquiring this GPIO non-exclusively expose the hardware state to being
inadvertently destroyed?
Because gpiolib does not implement reference counting for non-exclusive
consumers, any call to gpiod_put() will execute gpiod_free_commit():
drivers/gpio/gpiolib.c:gpiod_free_commit() {
...
clear_bit(GPIOD_FLAG_REQUESTED, &flags);
...
}
This unconditionally frees the GPIO hardware state. Since gpio_trig_activate()
calls gpiod_put() on its error path and during deactivation, won't this tear
down the primary owner's (e.g., the SFP driver's) hardware state?
[Severity: High]
Will this IRQ sharing strategy actually work with the SFP driver?
In gpio_trig_activate(), the LED trigger requests the IRQ with IRQF_SHARED:
ret = request_threaded_irq(gpiod_to_irq(gpio_data->gpiod), NULL,
gpio_trig_irq,
IRQF_ONESHOT | IRQF_SHARED | IRQF_TRIGGER_RISING
| IRQF_TRIGGER_FALLING, "ledtrig-gpio", led);
However, the primary SFP driver requests the same IRQ exclusively:
drivers/net/phy/sfp.c:sfp_probe() {
...
err = devm_request_threaded_irq(sfp->dev, sfp->gpio_irq[i],
NULL, sfp_irq,
IRQF_ONESHOT |
IRQF_TRIGGER_RISING |
IRQF_TRIGGER_FALLING,
sfp_irq_name, sfp);
...
}
Since the kernel's IRQ core strictly requires all consumers to use IRQF_SHARED
for sharing to succeed, won't request_threaded_irq() always return -EBUSY?
If this always fails, it will trigger the error path that calls gpiod_put(),
which leads to the destructive GPIO teardown mentioned above.
[Severity: Medium]
Could this overwrite the original owner's consumer label?
Right after acquiring the GPIO, the trigger driver forcibly sets the
consumer name:
gpiod_set_consumer_name(gpio_data->gpiod, "led-trigger");
The underlying gpiolib implementation completely overwrites and frees the
old label:
drivers/gpio/gpiolib.c:desc_set_label() {
...
old = rcu_replace_pointer(desc->label, new, 1);
if (old)
call_srcu(&desc->gdev->desc_srcu, &old->rh, desc_free_label);
...
}
Won't this erase the primary driver's label and corrupt the consumer
tracking for debugging interfaces like debugfs and sysfs? Furthermore, if the
LED trigger fails or deactivates, won't desc_set_label() clear the label
entirely to NULL, permanently masking the primary driver's ownership?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260831133314.4125787-347-sashal@kernel.org?part=1
next prev parent reply other threads:[~2026-08-31 15:49 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20260831133314.4125787-1-sashal@kernel.org>
2026-08-31 13:23 ` [PATCH AUTOSEL 6.18] leds: core: Fix race condition for software blink Sasha Levin
2026-08-31 14:50 ` sashiko-bot
2026-08-31 13:23 ` [PATCH AUTOSEL 6.18-5.10] leds: pca9532: Don't stop blinking for non-zero brightness Sasha Levin
2026-08-31 14:58 ` sashiko-bot
2026-08-31 13:26 ` [PATCH AUTOSEL 6.18-6.12] leds: trigger: gpio: Use GPIOD_FLAGS_BIT_NONEXCLUSIVE Sasha Levin
2026-08-31 15:49 ` sashiko-bot [this message]
2026-08-31 13:29 ` [PATCH AUTOSEL 6.18-5.10] leds: uleds: Return -EFAULT on copy_to_user() failure Sasha Levin
2026-08-31 17:13 ` sashiko-bot
2026-08-31 13:29 ` [PATCH AUTOSEL 6.18] leds: tps6131x: Increase overvoltage protection threshold to 6V Sasha Levin
2026-08-31 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=20260831154936.4EFF21F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=lee@kernel.org \
--cc=linux-leds@vger.kernel.org \
--cc=sashal@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