[PATCH] of: unittest: Fix np reference leak in of_unittest_printf()
From: Wentao Liang
Date: Thu Sep 17 2026 - 09:15:15 EST
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@xxxxxxxxxxxxxxx
Signed-off-by: Wentao Liang <vulab@xxxxxxxxxxx>
---
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