leds: lm3692x: Fix regulator/gpio leak and wrong enabled state on last write failure

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: 260718b3a3 ("leds: lm3692x: Disable chip on brightness 0")
Assisted-by: Claude:claude-opus-4
Signed-off-by: Cong Nguyen <congnt264@gmail.com>
Link: https://patch.msgid.link/20260915034515.4147981-1-congnt264@gmail.com
Signed-off-by: Lee Jones <lee@kernel.org>
This commit is contained in:
Cong Nguyen 2026-09-15 10:45:15 +07:00 committed by Lee Jones
parent 1b75f038e5
commit 145ca6bca2

View File

@ -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");