From: Miaoqian Lin <linmq006@gmail.com>
To: Madhavan Srinivasan <maddy@linux.ibm.com>,
Michael Ellerman <mpe@ellerman.id.au>,
Nicholas Piggin <npiggin@gmail.com>,
Christophe Leroy <christophe.leroy@csgroup.eu>,
"Jiri Slaby (SUSE)" <jirislaby@kernel.org>,
Thomas Gleixner <tglx@linutronix.de>,
Albert Herranz <albert_herranz@yahoo.es>,
Grant Likely <grant.likely@secretlab.ca>,
Segher Boessenkool <segher@kernel.crashing.org>,
linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org
Cc: linmq006@gmail.com, stable@vger.kernel.org
Subject: [PATCH] powerpc/flipper-pic: Fix device node reference leak in flipper_pic_init
Date: Mon, 27 Oct 2025 23:09:11 +0800 [thread overview]
Message-ID: <20251027150914.59811-1-linmq006@gmail.com> (raw)
The flipper_pic_init() function calls of_get_parent() which increases
the device node reference count, but fails to call of_node_put() to
balance the reference count.
Add calls to of_node_put() in all paths to fix the leak.
Found via static analysis.
Fixes: 028ee972f032 ("powerpc: gamecube/wii: flipper interrupt controller support")
Cc: stable@vger.kernel.org
Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
---
arch/powerpc/platforms/embedded6xx/flipper-pic.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/arch/powerpc/platforms/embedded6xx/flipper-pic.c b/arch/powerpc/platforms/embedded6xx/flipper-pic.c
index 91a8f0a7086e..cf6f795c8d76 100644
--- a/arch/powerpc/platforms/embedded6xx/flipper-pic.c
+++ b/arch/powerpc/platforms/embedded6xx/flipper-pic.c
@@ -135,13 +135,13 @@ static struct irq_domain * __init flipper_pic_init(struct device_node *np)
}
if (!of_device_is_compatible(pi, "nintendo,flipper-pi")) {
pr_err("unexpected parent compatible\n");
- goto out;
+ goto out_put_node;
}
retval = of_address_to_resource(pi, 0, &res);
if (retval) {
pr_err("no io memory range found\n");
- goto out;
+ goto out_put_node;
}
io_base = ioremap(res.start, resource_size(&res));
@@ -154,9 +154,12 @@ static struct irq_domain * __init flipper_pic_init(struct device_node *np)
&flipper_irq_domain_ops, io_base);
if (!irq_domain) {
pr_err("failed to allocate irq_domain\n");
+ of_node_put(pi);
return NULL;
}
+out_put_node:
+ of_node_put(pi);
out:
return irq_domain;
}
--
2.39.5 (Apple Git-154)
next reply other threads:[~2025-10-27 15:09 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-27 15:09 Miaoqian Lin [this message]
2025-11-04 17:26 ` [PATCH] powerpc/flipper-pic: Fix device node reference leak in flipper_pic_init Christophe Leroy
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=20251027150914.59811-1-linmq006@gmail.com \
--to=linmq006@gmail.com \
--cc=albert_herranz@yahoo.es \
--cc=christophe.leroy@csgroup.eu \
--cc=grant.likely@secretlab.ca \
--cc=jirislaby@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=maddy@linux.ibm.com \
--cc=mpe@ellerman.id.au \
--cc=npiggin@gmail.com \
--cc=segher@kernel.crashing.org \
--cc=stable@vger.kernel.org \
--cc=tglx@linutronix.de \
/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;
as well as URLs for NNTP newsgroup(s).