[PATCH 12/21] leds: aat1290: Retain child device_node reference for device lifetime
From: Lee Jones
Date: Wed Oct 21 2026 - 08:54:17 EST
aat1290_led_parse_dt() acquires a child device_node with the
__free(device_node) cleanup attribute and assigns it directly to the
*sub_node output parameter without consuming the pointer via
no_free_ptr(). Consequently, of_node_put() is called automatically when
aat1290_led_parse_dt() returns, leaving aat1290_led_probe() with a
dangling pointer when it passes the firmware node to
led_classdev_flash_register_ext() and v4l2_flash_init().
Because the LED core stores init_data.fwnode via device_set_node()
without taking an additional reference of its own, consume child_node
with no_free_ptr() and register a devm action to release the reference
when the device is unbound or probe fails.
Fixes: ac69b9038f82 ("leds: aat1290: add support for V4L2 Flash sub-device")
Fixes: 1e63395e58b2 ("leds: aat1290: Use scoped device node handling to simplify error paths")
Closes: https://sashiko.dev/#/bug/linux-2255c65e-840f-49ab-9dc5-227a4eab4c37
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Lee Jones <lee@xxxxxxxxxx>
---
drivers/leds/flash/leds-aat1290.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/drivers/leds/flash/leds-aat1290.c b/drivers/leds/flash/leds-aat1290.c
index 4bde0b07fe78..ea9af6c3fbf4 100644
--- a/drivers/leds/flash/leds-aat1290.c
+++ b/drivers/leds/flash/leds-aat1290.c
@@ -211,6 +211,11 @@ static int aat1290_led_flash_timeout_set(struct led_classdev_flash *fled_cdev,
return 0;
}
+static void aat1290_of_node_put(void *data)
+{
+ of_node_put(data);
+}
+
static int aat1290_led_parse_dt(struct aat1290_led *led,
struct aat1290_led_config_data *cfg,
struct device_node **sub_node)
@@ -279,9 +284,9 @@ static int aat1290_led_parse_dt(struct aat1290_led *led,
return ret;
}
- *sub_node = child_node;
+ *sub_node = no_free_ptr(child_node);
- return 0;
+ return devm_add_action_or_reset(dev, aat1290_of_node_put, *sub_node);
}
static void aat1290_led_validate_mm_current(struct aat1290_led *led,
--
2.56.0.218.g1ec904b173-goog