Skip to contentSkip to conversation

leds: flash: tps6131x: put the LED child node reference

PATCH New Cong Nguyen 2 participants 2 messages Nov 24

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 leds: flash: tps6131x: put the LED child node reference

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")
---
 drivers/leds/flash/leds-tps6131x.c | 9 +++++++++
 1 file changed, 9 insertions(+)
drivers/leds/flash/leds-tps6131x.c +9 -0
index 7f2c3895e6e9..56de7a1cf9a7 100644
@@ -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");
Signature · 1 line
2.25.1
#1 lore raw
Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [Low] leds: tps6131x: commit subject violates LEDs subsystem naming convention --

Thank you for your contribution! Sashiko AI review found 1 potential issue to consider:
- [Low] leds: tps6131x: commit subject violates LEDs subsystem naming convention
--

commit e59e64da27879f33579f6bb41280340b0228e4fe
Author: Cong Nguyen <[email protected]>

leds: flash: tps6131x: put the LED child node reference

This commit registers a devm action in tps6131x_parse_node() to release the fwnode reference obtained from device_get_next_child_node().

Quoted 1 line

leds: flash: tps6131x: put the LED child node reference

[Severity: Low]
This isn't a bug, but LEDs subsystem commit subjects follow the "leds: <driver>: <Capitalized description>" format, so this subject should be:

leds: tps6131x: Put the LED child node reference

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1