drivers/leds/leds-lm3692x.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
Every write in lm3692x_leds_enable() checks its return and jumps to
out: on failure -- except the last one, which falls through and sets
led->enabled = true regardless of whether it actually succeeded. Leaks
the regulator on a failing probe, and short-circuits later
brightness_set() calls without retrying.
Route it through out: like every other write here, and only set
enabled = true once it succeeds.
Fixes: 260718b3a35d ("leds: lm3692x: Disable chip on brightness 0")
Assisted-by: Claude:claude-opus-4
Signed-off-by: Cong Nguyen <congnt264@gmail.com>
---
drivers/leds/leds-lm3692x.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/leds/leds-lm3692x.c b/drivers/leds/leds-lm3692x.c
index 8d2678dc9e4f..9c58d54c5783 100644
--- a/drivers/leds/leds-lm3692x.c
+++ b/drivers/leds/leds-lm3692x.c
@@ -276,9 +276,11 @@ static int lm3692x_leds_enable(struct lm3692x_led *led)
ret = regmap_update_bits(led->regmap, LM3692X_EN, LM3692X_ENABLE_MASK,
enable_state | LM3692X_DEVICE_EN);
+ if (ret)
+ goto out;
led->enabled = true;
- return ret;
+ return 0;
out:
dev_err(&led->client->dev, "Fail writing initialization values\n");
--
2.25.1
On Tue, 15 Sep 2026 10:45:15 +0700, Cong Nguyen wrote:
> Every write in lm3692x_leds_enable() checks its return and jumps to
> out: on failure -- except the last one, which falls through and sets
> led->enabled = true regardless of whether it actually succeeded. Leaks
> the regulator on a failing probe, and short-circuits later
> brightness_set() calls without retrying.
>
> Route it through out: like every other write here, and only set
> enabled = true once it succeeds.
>
> [...]
Applied, thanks!
[1/1] leds: lm3692x: fix regulator/gpio leak and wrong enabled state on last write failure
commit: 145ca6bca2cc5fd8d9c7af216df58a9c75c0e84c
--
Lee Jones [李琼斯]
© 2016 - 2026 Red Hat, Inc.