[PATCH 01/21] leds: lm3532: Propagate error from devm_regulator_get()

From: Lee Jones

Date: Wed Oct 21 2026 - 08:46:48 EST


lm3532_parse_node() catches errors from devm_regulator_get() and sets
priv->regulator to NULL. Because devm_regulator_get() already returns a
dummy regulator when the supply is omitted in Device Tree, an error
pointer is only returned on a genuine failure such as -EPROBE_DEFER.

Masking that error as NULL both breaks probe deferral when a supply is
specified and causes a NULL pointer dereference in regulator_enable()
and regulator_disable() when the LED brightness is later modified via
lm3532_led_enable() or lm3532_led_disable().

Propagate the error code from devm_regulator_get() instead.

Fixes: bc1b8492c764 ("leds: lm3532: Introduce the lm3532 LED driver")
Closes: https://sashiko.dev/#/bug/linux-8836989c-356e-4601-ac4c-6db97861cb00
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Lee Jones <lee@xxxxxxxxxx>
---
drivers/leds/leds-lm3532.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/leds/leds-lm3532.c b/drivers/leds/leds-lm3532.c
index b51496910b08..7f849a166a92 100644
--- a/drivers/leds/leds-lm3532.c
+++ b/drivers/leds/leds-lm3532.c
@@ -570,7 +570,7 @@ static int lm3532_parse_node(struct lm3532_data *priv)

priv->regulator = devm_regulator_get(&priv->client->dev, "vin");
if (IS_ERR(priv->regulator))
- priv->regulator = NULL;
+ return PTR_ERR(priv->regulator);

ret = device_property_read_u32(&priv->client->dev, "ramp-up-us",
&ramp_time);
--
2.56.0.218.g1ec904b173-goog