mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] of: unittest: Fix np reference leak in of_unittest_parse_phandle_with_args_map()
@ 2026-09-17 12:59 Wentao Liang
  0 siblings, 0 replies; only message in thread
From: Wentao Liang @ 2026-09-17 12:59 UTC (permalink / raw)
  To: devicetree
  Cc: linux-kernel, robh, saravanak, stephen.boyd, Wentao Liang, stable

of_find_node_by_path() returns a node with an elevated reference count,
but the function returns without dropping it both when a provider node
is missing and after the last check. Add the missing of_node_put() calls.

Fixes: 357aa4b61c82 ("of: unittest: Add phandle remapping test")
Cc: stable@vger.kernel.org
Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
---
 drivers/of/unittest.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/of/unittest.c b/drivers/of/unittest.c
index 36c64d485a53..e10fff3f68c4 100644
--- a/drivers/of/unittest.c
+++ b/drivers/of/unittest.c
@@ -581,6 +581,7 @@ static void __init of_unittest_parse_phandle_with_args_map(void)
 	for (i = 0; i < ARRAY_SIZE(p); ++i) {
 		if (!p[i]) {
 			pr_err("missing testcase data\n");
+			of_node_put(np);
 			return;
 		}
 		prefs[i] = OF_KREF_READ(p[i]);
@@ -711,6 +712,8 @@ static void __init of_unittest_parse_phandle_with_args_map(void)
 			 i, prefs[i], OF_KREF_READ(p[i]));
 		of_node_put(p[i]);
 	}
+
+	of_node_put(np);
 }
 
 static void __init of_unittest_property_string(void)
-- 
2.34.1


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2026-09-17 12:59 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-17 12:59 [PATCH] of: unittest: Fix np reference leak in of_unittest_parse_phandle_with_args_map() Wentao Liang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®