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

Every iteration takes a reference with of_find_node_by_path() but the
loop never drops it, neither on the early continue paths nor after a
successful match. Add the missing of_node_put() calls.

Fixes: 1f42e5dd5065 ("of: Add self test for of_match_node()")
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 316f082c430d..900840850814 100644
--- a/drivers/of/unittest.c
+++ b/drivers/of/unittest.c
@@ -1897,6 +1897,7 @@ static void __init of_unittest_match_node(void)
 		if (!match) {
 			unittest(0, "%s didn't match anything\n",
 				match_node_tests[i].path);
+			of_node_put(np);
 			continue;
 		}
 
@@ -1904,9 +1905,11 @@ static void __init of_unittest_match_node(void)
 			unittest(0, "%s got wrong match. expected %s, got %s\n",
 				match_node_tests[i].path, match_node_tests[i].data,
 				(const char *)match->data);
+			of_node_put(np);
 			continue;
 		}
 		unittest(1, "passed");
+		of_node_put(np);
 	}
 }
 
-- 
2.34.1


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

only message in thread, other threads:[~2026-09-17 12:55 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:55 [PATCH] of: unittest: Fix np reference leak in of_unittest_match_node() 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®