From: sashiko-bot@kernel.org
To: "Daniil Demakov" <t3127430@gmail.com>
Cc: linux-leds@vger.kernel.org, lee@kernel.org
Subject: Re: [PATCH] leds: pca9532: Propagate I2C errors
Date: Sat, 28 Nov 2026 22:40:02 +0000 [thread overview]
Message-ID: <sashiko-outbox-239114@kernel.org> (raw)
In-Reply-To: <20261128223052.215375-1-t3127430@gmail.com>
Thank you for your contribution! Sashiko AI review found 4 potential
issues to consider:
- [High] leds: pca9532: missing led_classdev_unregister() in
pca9532_configure()
- [Medium] leds: pca9532: stale PCA9532_PWM1 state on error in
pca9532_set_blink()
- [Medium] leds: pca9532: ignored error return in
pca9532_gpio_direction_input()
- [Low] leds: pca9532: empty commit description body
--
commit cfd64d8a31c7a13a716f2c043b0af231a835bd23
Author: Daniil Demakov <t3127430@gmail.com>
> leds: pca9532: Propagate I2C errors
>
> Signed-off-by: Daniil Demakov <t3127430@gmail.com>
[Severity: Low]
This commit has an empty changelog body. Could a short description
explaining what is changed and why be added?
> diff --git a/drivers/leds/leds-pca9532.c b/drivers/leds/leds-pca9532.c
> index c8085427696ff..09735f06c8901 100644
> --- a/drivers/leds/leds-pca9532.c
> +++ b/drivers/leds/leds-pca9532.c
[ ... ]
> @@ -257,9 +277,9 @@ static int pca9532_set_blink(struct led_classdev *led_cdev,
> if (err)
> return err;
>
> - pca9532_setled(led);
> + err = pca9532_setled(led);
>
> - return 0;
> + return err;
> }
[Severity: Medium]
Does returning an error here leave led->state stuck at PCA9532_PWM1?
pca9532_update_hw_blink() sets led->state = PCA9532_PWM1 before
pca9532_setled() runs. When pca9532_set_blink() returns a non-zero
error, led_blink_setup() falls back to software blinking, but
pca9532_set_brightness() ignores non-zero brightness updates while
led->state == PCA9532_PWM1:
drivers/leds/leds-pca9532.c:pca9532_set_brightness() {
if (value == LED_OFF) {
led->state = PCA9532_OFF;
} else if (led->state == PCA9532_PWM1) {
return 0; /* Non-zero brightness shall not stop HW blinking */
}
As a result, software blink ticks and manual non-zero brightness writes
cannot turn the LED on.
> @@ -328,15 +348,15 @@ static int pca9532_gpio_set_value(struct gpio_chip *gc, unsigned int offset,
> {
> struct pca9532_data *data = gpiochip_get_data(gc);
> struct pca9532_led *led = &data->leds[offset];
> -
> + int err;
> if (val)
> led->state = PCA9532_OFF;
> else
> led->state = PCA9532_ON;
>
> - pca9532_setled(led);
> + err = pca9532_setled(led);
>
> - return 0;
> + return err;
> }
[Severity: Medium]
Should pca9532_gpio_direction_input() also return the error from
pca9532_gpio_set_value()?
drivers/leds/leds-pca9532.c:pca9532_gpio_direction_input() {
/* To use as input ensure pin is not driven */
pca9532_gpio_set_value(gc, offset, 1);
return 0;
}
If pca9532_setled() fails when releasing the open-drain pin,
pca9532_gpio_direction_input() discards the error and reports success
while the pin may remain driven low.
> @@ -442,14 +462,18 @@ static int pca9532_configure(struct i2c_client *client,
> led->name);
> goto exit;
> }
> - pca9532_setled(led);
> + err = pca9532_setled(led);
> + if (err)
> + goto exit;
> break;
[Severity: High]
If pca9532_setled() fails here, does jumping to exit leave led->ldev
registered?
led_classdev_register() has already succeeded for index i, and the exit
label calls pca9532_destroy_devices(data, i), which only unregisters
indices i - 1 down to 0:
drivers/leds/leds-pca9532.c:pca9532_destroy_devices() {
int i = n_devs;
while (--i >= 0) {
switch (data->leds[i].type) {
...
case PCA9532_TYPE_LED:
led_classdev_unregister(&data->leds[i].ldev);
break;
}
When pca9532_probe() then fails, devres frees data while
data->leds[i].ldev remains registered in the LED core, leading to a
use-after-free. Calling pca9532_setled(led) before
led_classdev_register() would avoid this.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261128223052.215375-1-t3127430@gmail.com?part=1
next prev parent reply other threads:[~2026-11-28 22:40 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-28 22:30 [PATCH] leds: pca9532: Propagate I2C errors Daniil Demakov
2026-11-28 22:40 ` sashiko-bot [this message]
-- strict thread matches above, loose matches on Subject: below --
2026-11-28 22:59 Daniil Demakov
2026-11-28 23:09 ` sashiko-bot
2026-11-17 7:05 Daniil Demakov
2026-11-17 7:22 ` sashiko-bot
2026-11-14 14:19 Daniil Demakov
2026-11-14 14:32 ` 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-239114@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=lee@kernel.org \
--cc=linux-leds@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=t3127430@gmail.com \
/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