Linux LED subsystem development
 help / color / mirror / Atom feed
* [PATCH] leds: flash: tps6131x: put the LED child node reference
@ 2026-11-24 10:11 Cong Nguyen
  2026-11-24 10:19 ` sashiko-bot
  0 siblings, 1 reply; 2+ messages in thread
From: Cong Nguyen @ 2026-11-24 10:11 UTC (permalink / raw)
  To: Matthias Fend, Lee Jones, Pavel Machek; +Cc: linux-leds, linux-kernel

tps6131x_parse_node() gets the LED child node with
device_get_next_child_node(), which takes a reference. The driver never
drops it, so the reference is leaked on every probe error and after
remove().

Drop it with a device managed action registered right after the node is
taken, as leds-tps6105x does.

This issue was found by auditing the driver with an LLM coding assistant.

Fixes: b338a2ae9b31 ("leds: tps6131x: Add support for Texas Instruments TPS6131X flash LED driver")
Signed-off-by: Cong Nguyen <congnt264@gmail.com>
---
 drivers/leds/flash/leds-tps6131x.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/drivers/leds/flash/leds-tps6131x.c b/drivers/leds/flash/leds-tps6131x.c
index 7f2c3895e6e9..56de7a1cf9a7 100644
--- a/drivers/leds/flash/leds-tps6131x.c
+++ b/drivers/leds/flash/leds-tps6131x.c
@@ -529,6 +529,11 @@ static const struct led_flash_ops flash_ops = {
 	.fault_get = tps6131x_flash_fault_get,
 };
 
+static void tps6131x_led_node_put(void *data)
+{
+	fwnode_handle_put(data);
+}
+
 static int tps6131x_parse_node(struct tps6131x *tps6131x)
 {
 	const struct tps6131x_timer_config *timer_config;
@@ -550,6 +555,10 @@ static int tps6131x_parse_node(struct tps6131x *tps6131x)
 		return -EINVAL;
 	}
 
+	ret = devm_add_action_or_reset(dev, tps6131x_led_node_put, tps6131x->led_node);
+	if (ret)
+		return ret;
+
 	num_channels = fwnode_property_count_u32(tps6131x->led_node, "led-sources");
 	if (num_channels <= 0) {
 		dev_err(dev, "Failed to read led-sources property\n");
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-11-24 10:19 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-24 10:11 [PATCH] leds: flash: tps6131x: put the LED child node reference Cong Nguyen
2026-11-24 10:19 ` sashiko-bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox