[PATCH] of: unittest: Fix np reference leak in of_unittest_bus_ranges()

Wentao Liang posted 1 patch 1 week ago
drivers/of/unittest.c | 1 +
1 file changed, 1 insertion(+)
[PATCH] of: unittest: Fix np reference leak in of_unittest_bus_ranges()
Posted by Wentao Liang 1 week ago
of_range_parser_init() can fail when the node lacks a ranges property.
That error path returns without dropping the reference taken by
of_find_node_by_path(). Add the missing of_node_put().

Fixes: 6d32dadb11a6 ("of: unittest: Add bus address range parsing tests")
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 e8257aff17b3..5c90be158dd5 100644
--- a/drivers/of/unittest.c
+++ b/drivers/of/unittest.c
@@ -1280,6 +1280,7 @@ static void __init of_unittest_bus_ranges(void)
 
 	if (of_range_parser_init(&parser, np)) {
 		pr_err("missing ranges property\n");
+		of_node_put(np);
 		return;
 	}
 
-- 
2.34.1