* [PATCH] of: unittest: fix node reference leak in of_unittest_match_node()
@ 2026-11-03 10:42 Wentao Liang
2026-11-03 11:10 ` Krzysztof Kozlowski
2026-11-05 15:42 ` sashiko-bot
0 siblings, 2 replies; 3+ messages in thread
From: Wentao Liang @ 2026-11-03 10:42 UTC (permalink / raw)
To: Rob Herring, Saravana Kannan
Cc: devicetree, linux-kernel, Wentao Liang, stable
of_find_node_by_path() returns a device_node with its reference count
incremented. of_unittest_match_node() never releases that reference:
failed matches continue to the next iteration, and the reference taken
for the last test case is still held when the function returns.
Drop the reference on all three paths.
Fixes: 1f42e5dd5065 ("of: Add self test for of_match_node()")
Cc: stable@vger.kernel.org
Assisted-by: DeepSeek-V4.1-Flash and OpenAI Codex
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 e255f54f4d76..7426d13e9958 100644
--- a/drivers/of/unittest.c
+++ b/drivers/of/unittest.c
@@ -1921,6 +1921,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;
}
@@ -1928,9 +1929,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 related [flat|nested] 3+ messages in thread* Re: [PATCH] of: unittest: fix node reference leak in of_unittest_match_node()
2026-11-03 10:42 [PATCH] of: unittest: fix node reference leak in of_unittest_match_node() Wentao Liang
@ 2026-11-03 11:10 ` Krzysztof Kozlowski
2026-11-05 15:42 ` sashiko-bot
1 sibling, 0 replies; 3+ messages in thread
From: Krzysztof Kozlowski @ 2026-11-03 11:10 UTC (permalink / raw)
To: Wentao Liang
Cc: Saravana Kannan, linux-kernel, stable, devicetree, Rob Herring
On Tue, 03 Nov 2026 10:42:37 +0000, Wentao Liang wrote:
> of_find_node_by_path() returns a device_node with its reference count
> incremented. of_unittest_match_node() never releases that reference:
> failed matches continue to the next iteration, and the reference taken
> for the last test case is still held when the function returns.
>
> Drop the reference on all three paths.
>
> Fixes: 1f42e5dd5065 ("of: Add self test for of_match_node()")
> Cc: stable@vger.kernel.org
> Assisted-by: DeepSeek-V4.1-Flash and OpenAI Codex
> Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
> ---
> drivers/of/unittest.c | 3 +++
> 1 file changed, 3 insertions(+)
>
Multiple things here:
1. Your team ignored completely previous feedback. Multiple times.
2. You use multiple identities with this email address, thus I doubt that we
speak with an actual person.
3. Your bot does not even bother running checkpatch, right?
4. Nothing of this was reproduced nor tested.
5. Finally, the same feedback:
You sent multiple independent patches, to multiple independent
subsystems. The amount of these patches clearly suggest this was
AI generated and most likely not tested.
More importantly, you sent all this work without properly organizing
relevant patches into patchsets. This makes reviewing difficult
and might cause multiple reviewers to address the same issue.
Replying to the entire set is impossible and requires handling each
patch independently, instead of applying or discarding the set.
Maintainers also won't see the bigger picture of your work. Quite
worrying.
This is on the verge of hostile patch: bomb us with so many
contributions, we won't be able to handle them in efficient manner,
like responding ONCE to ask you to slow down. Considering all this
is untested and LLM generated, I have even more doubts whether this
should be considered for review.
Please read kernel documentation BEFORE posting more work. It will
explain you how to identify subsystems, how to organize your work per
subsystem (so a patchset grouping multiple patches with a short cover
letter), how to document the issue discovery method and what was
or was not tested.
Best regards,
Krzysztof
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] of: unittest: fix node reference leak in of_unittest_match_node()
2026-11-03 10:42 [PATCH] of: unittest: fix node reference leak in of_unittest_match_node() Wentao Liang
2026-11-03 11:10 ` Krzysztof Kozlowski
@ 2026-11-05 15:42 ` sashiko-bot
1 sibling, 0 replies; 3+ messages in thread
From: sashiko-bot @ 2026-11-05 15:42 UTC (permalink / raw)
To: Wentao Liang; +Cc: devicetree, robh, conor+dt
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Low] of: unittest: duplicated of_node_put() calls in of_unittest_match_node()
- [Low] of: unittest: inaccurate leak description in commit message for of_unittest_match_node()
--
commit af0b41164c2a3216ad75b00e05f54e6ed432774e
Author: Wentao Liang <vulab@iscas.ac.cn>
of: unittest: fix node reference leak in of_unittest_match_node()
This commit adds of_node_put(np) calls across the match failure and success
paths in of_unittest_match_node() to release the device_node reference
acquired by of_find_node_by_path().
> of: unittest: fix node reference leak in of_unittest_match_node()
>
> of_find_node_by_path() returns a device_node with its reference count
> incremented. of_unittest_match_node() never releases that reference:
> failed matches continue to the next iteration, and the reference taken
> for the last test case is still held when the function returns.
>
> Drop the reference on all three paths.
>
> Fixes: 1f42e5dd5065 ("of: Add self test for of_match_node()")
> Cc: stable@vger.kernel.org
> Assisted-by: DeepSeek-V4.1-Flash and OpenAI Codex
> Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
[Severity: Low]
This isn't a bug in the code, but is the commit message description of how
references are leaked accurate?
In drivers/of/unittest.c:of_unittest_match_node():
for (i = 0; i < ARRAY_SIZE(match_node_tests); i++) {
np = of_find_node_by_path(match_node_tests[i].path);
Unlike iterator helpers that take a previous node argument and release it,
of_find_node_by_path() only takes a path string and never drops the prior
reference held in np.
Doesn't overwriting np on the next iteration leak the device_node reference on
every passing test case as well, rather than only on failed matches and the
final test case?
> diff --git a/drivers/of/unittest.c b/drivers/of/unittest.c
> index e255f54f4d760..7426d13e99580 100644
> --- a/drivers/of/unittest.c
> +++ b/drivers/of/unittest.c
> @@ -1921,6 +1921,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;
> }
>
> @@ -1928,9 +1929,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);
[Severity: Low]
This isn't a bug, but in drivers/of/unittest.c:of_unittest_match_node(), np is
not used after being passed to of_match_node():
match = of_match_node(match_node_table, np);
Could of_node_put(np) be called once immediately after of_match_node() (or
could np be declared with __free(device_node) inside the loop) instead of
duplicating of_node_put(np) across all three exit paths?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261103104237.1373649-1-vulab@iscas.ac.cn?part=1
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-11-05 15:42 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-03 10:42 [PATCH] of: unittest: fix node reference leak in of_unittest_match_node() Wentao Liang
2026-11-03 11:10 ` Krzysztof Kozlowski
2026-11-05 15:42 ` sashiko-bot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox