From: Wentao Liang <vulab@iscas.ac.cn>
To: devicetree@vger.kernel.org
Cc: grant.likely@linaro.org, linux-kernel@vger.kernel.org,
robh@kernel.org, saravanak@kernel.org,
Wentao Liang <vulab@iscas.ac.cn>,
stable@vger.kernel.org
Subject: [PATCH] of: unittest: Fix np reference leaks in of_unittest_platform_populate()
Date: Thu, 17 Sep 2026 13:04:45 +0000 [thread overview]
Message-ID: <20260917130445.2152694-1-vulab@iscas.ac.cn> (raw)
np holds a reference obtained from of_find_node_by_path() but is
reassigned several times without a matching of_node_put(). Drop the
reference before each reassignment so it is not leaked on any path
through the function.
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 | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/of/unittest.c b/drivers/of/unittest.c
index 6bc5babddf0a..4a8af9b992c4 100644
--- a/drivers/of/unittest.c
+++ b/drivers/of/unittest.c
@@ -1934,6 +1934,7 @@ static void __init of_unittest_platform_populate(void)
np = of_find_node_by_path("/testcase-data");
of_platform_default_populate(np, NULL, NULL);
+ of_node_put(np);
/* Test that a missing irq domain returns -EPROBE_DEFER */
np = of_find_node_by_path("/testcase-data/testcase-device1");
@@ -1944,6 +1945,7 @@ static void __init of_unittest_platform_populate(void)
irq = platform_get_irq(pdev, 0);
unittest(irq == -EPROBE_DEFER,
"device deferred probe failed - %d\n", irq);
+ of_node_put(np);
/* Test that a parsing failure does not return -EPROBE_DEFER */
np = of_find_node_by_path("/testcase-data/testcase-device2");
@@ -1961,6 +1963,7 @@ static void __init of_unittest_platform_populate(void)
unittest(irq < 0 && irq != -EPROBE_DEFER,
"device parsing error failed - %d\n", irq);
}
+ of_node_put(np);
np = of_find_node_by_path("/testcase-data/platform-tests");
unittest(np, "No testcase data in device tree\n");
--
2.34.1
reply other threads:[~2026-09-17 13:04 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260917130445.2152694-1-vulab@iscas.ac.cn \
--to=vulab@iscas.ac.cn \
--cc=devicetree@vger.kernel.org \
--cc=grant.likely@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=robh@kernel.org \
--cc=saravanak@kernel.org \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox