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

Wentao Liang posted 1 patch 1 week ago
drivers/of/unittest.c | 1 +
1 file changed, 1 insertion(+)
[PATCH] of: unittest: Fix dup node reference leak in attach_node_and_children()
Posted by Wentao Liang 1 week ago
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@vger.kernel.org
Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
---
 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