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

Wentao Liang posted 1 patch 1 week ago
drivers/of/unittest.c | 2 ++
1 file changed, 2 insertions(+)
[PATCH] of: unittest: Fix np reference leak in of_unittest_printf()
Posted by Wentao Liang 1 week ago
of_find_node_by_path() returns a node with an elevated reference count,
but the function returns without ever dropping it. Add the missing
of_node_put() so the reference is not leaked.

Fixes: ce4fecf1fe15 ("vsprintf: Add %p extension "%pOF" for device tree")
Cc: stable@vger.kernel.org
Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
---
 drivers/of/unittest.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/of/unittest.c b/drivers/of/unittest.c
index e6e938bcb100..340e23725d7a 100644
--- a/drivers/of/unittest.c
+++ b/drivers/of/unittest.c
@@ -354,6 +354,8 @@ static void __init of_unittest_printf(void)
 	of_unittest_printf_one(np, "%pOFc", "test-sub-device");
 	of_unittest_printf_one(np, "%pOFC",
 			"\"test-sub-device\",\"test-compat2\",\"test-compat3\"");
+
+	of_node_put(np);
 }
 
 struct node_hash {
-- 
2.34.1