[PATCH] of: unittest: Fix dup node reference leak in attach_node_and_children()

From: Wentao Liang

Date: Thu Sep 17 2026 - 09:51:02 EST


of_find_node_by_path() returns a node with an elevated reference count.
When a matching node is found in the live tree the function updates the
node properties and returns without dropping that reference. Add the
missing of_node_put() so the reference is not leaked.

Fixes: ae9304c9d311 ("Adding selftest testdata dynamically into live tree")
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Wentao Liang <vulab@xxxxxxxxxxx>
---
drivers/of/unittest.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/drivers/of/unittest.c b/drivers/of/unittest.c
index 4078569a0f96..c4d4c10ceaa2 100644
--- a/drivers/of/unittest.c
+++ b/drivers/of/unittest.c
@@ -2072,6 +2072,7 @@ static void attach_node_and_children(struct device_node *np)
kfree(full_name);
if (dup) {
update_node_properties(np, dup);
+ of_node_put(dup);
return;
}

--
2.34.1