* [PATCH] sbus: fix device node leak in openprom_init()
@ 2026-12-04 12:40 Yuwei Chen
2026-12-04 13:23 ` sashiko-bot
0 siblings, 1 reply; 2+ messages in thread
From: Yuwei Chen @ 2026-12-04 12:40 UTC (permalink / raw)
To: David S . Miller, Andreas Larsson; +Cc: sparclinux
openprom_init() looks up "/" with of_find_node_by_path() and passes
that node to of_get_child_by_name(). The child lookup takes its own
reference on "options" and does not drop the root. The root pointer
is discarded. "options" is kept for the life of the driver and is not
dropped in openprom_cleanup().
The root reference has been leaked since sparc started using the
generic OF lookup, which increments the refcount. The "options"
reference was added when the open-coded sibling walk was replaced by
of_get_child_by_name().
Drop the root after the child lookup. Drop "options" when the module
unloads.
Fixes: a88b5ba8bd8a ("sparc,sparc64: unify kernel/")
Fixes: df58f37b5d8f ("sbus: Use of_get_child_by_name helper")
Cc: stable@vger.kernel.org
Signed-off-by: Yuwei Chen <2522445001@qq.com>
---
drivers/sbus/char/openprom.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/drivers/sbus/char/openprom.c b/drivers/sbus/char/openprom.c
index 0b90a2450429..db55c3c0c34f 100644
--- a/drivers/sbus/char/openprom.c
+++ b/drivers/sbus/char/openprom.c
@@ -702,12 +702,15 @@ static struct miscdevice openprom_dev = {
static int __init openprom_init(void)
{
int err;
+ struct device_node *root;
err = misc_register(&openprom_dev);
if (err)
return err;
- options_node = of_get_child_by_name(of_find_node_by_path("/"), "options");
+ root = of_find_node_by_path("/");
+ options_node = of_get_child_by_name(root, "options");
+ of_node_put(root);
if (!options_node) {
misc_deregister(&openprom_dev);
return -EIO;
@@ -719,6 +722,7 @@ static int __init openprom_init(void)
static void __exit openprom_cleanup(void)
{
misc_deregister(&openprom_dev);
+ of_node_put(options_node);
}
module_init(openprom_init);
--
2.53.0.windows.2
base-commit: 007722b8211f7b34fdf21b1e6a9c32497633ea29
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] sbus: fix device node leak in openprom_init()
2026-12-04 12:40 [PATCH] sbus: fix device node leak in openprom_init() Yuwei Chen
@ 2026-12-04 13:23 ` sashiko-bot
0 siblings, 0 replies; 2+ messages in thread
From: sashiko-bot @ 2026-12-04 13:23 UTC (permalink / raw)
To: Yuwei Chen; +Cc: sparclinux
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] sbus: Fixes tag cites unrelated commit a88b5ba8bd8a
--
commit 5ed223b9ec480bcbbd1c3a4665050fd8fa592969
Author: Yuwei Chen <2522445001@qq.com>
> sbus: fix device node leak in openprom_init()
>
> openprom_init() looks up "/" with of_find_node_by_path() and passes
> that node to of_get_child_by_name(). The child lookup takes its own
> reference on "options" and does not drop the root. The root pointer
> is discarded. "options" is kept for the life of the driver and is not
> dropped in openprom_cleanup().
>
> The root reference has been leaked since sparc started using the
> generic OF lookup, which increments the refcount. The "options"
> reference was added when the open-coded sibling walk was replaced by
> of_get_child_by_name().
>
> Drop the root after the child lookup. Drop "options" when the module
> unloads.
>
> Fixes: a88b5ba8bd8a ("sparc,sparc64: unify kernel/")
> Fixes: df58f37b5d8f ("sbus: Use of_get_child_by_name helper")
> Cc: stable@vger.kernel.org
> Signed-off-by: Yuwei Chen <2522445001@qq.com>
[Severity: Low]
Does the first Fixes tag point to the right commit? Commit a88b5ba8bd8a
("sparc,sparc64: unify kernel/") only moved files under arch/sparc/ and
updated Makefiles. The commit that switched sparc to the refcounting
generic of_find_node_by_path() implementation in drivers/of/base.c is:
Fixes: 1ef4d4242d9c ("Consolidate of_find_node_by routines")
--
Sashiko AI review · https://sashiko.dev/#/patchset/tencent_DC660D945BBBF4A260290AD4396EBF242909@qq.com?part=1
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-12-04 13:23 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-04 12:40 [PATCH] sbus: fix device node leak in openprom_init() Yuwei Chen
2026-12-04 13:23 ` sashiko-bot
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.