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

The platform devices obtained with of_find_device_by_node() are never
released, and the second lookup overwrites the first one, losing its
reference as well. Drop each reference once the device has been used.

Fixes: 82c0f5897a87 ("of: selftest: add deferred probe interrupt test")
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 4a8af9b992c4..e6e938bcb100 100644
--- a/drivers/of/unittest.c
+++ b/drivers/of/unittest.c
@@ -1946,6 +1946,7 @@ static void __init of_unittest_platform_populate(void)
 		unittest(irq == -EPROBE_DEFER,
 			 "device deferred probe failed - %d\n", irq);
 		of_node_put(np);
+		platform_device_put(pdev);
 
 		/* Test that a parsing failure does not return -EPROBE_DEFER */
 		np = of_find_node_by_path("/testcase-data/testcase-device2");
@@ -1964,6 +1965,7 @@ static void __init of_unittest_platform_populate(void)
 			 "device parsing error failed - %d\n", irq);
 	}
 	of_node_put(np);
+	platform_device_put(pdev);
 
 	np = of_find_node_by_path("/testcase-data/platform-tests");
 	unittest(np, "No testcase data in device tree\n");
-- 
2.34.1


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

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

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-17 13:05 [PATCH] of: unittest: Fix pdev reference leaks in of_unittest_platform_populate() 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®