From: Yuho Choi <dbgh9129@gmail.com>
To: Russell King <linux@armlinux.org.uk>
Cc: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, Yuho Choi <dbgh9129@gmail.com>
Subject: [PATCH v1] ARM: l2x0: Fix OF node reference leak in l2x0_of_init
Date: Mon, 8 Jun 2026 00:23:30 -0400 [thread overview]
Message-ID: <20260608042331.2633217-1-dbgh9129@gmail.com> (raw)
l2x0_of_init() gets the cache controller node with
of_find_matching_node(), which returns the node with a reference held.
The node is only needed while parsing the cache controller resources and
properties, but the function returns without dropping that reference on
the resource/ioremap failure paths or after __l2c_init() returns.
Use a single exit path after the node lookup and put the node before
returning.
Fixes: 8c369264b6de ("ARM: 7009/1: l2x0: Add OF based initialization")
Signed-off-by: Yuho Choi <dbgh9129@gmail.com>
---
arch/arm/mm/cache-l2x0.c | 19 ++++++++++++++-----
1 file changed, 14 insertions(+), 5 deletions(-)
diff --git a/arch/arm/mm/cache-l2x0.c b/arch/arm/mm/cache-l2x0.c
index 470867160076..e20ac79dd500 100644
--- a/arch/arm/mm/cache-l2x0.c
+++ b/arch/arm/mm/cache-l2x0.c
@@ -1767,17 +1767,22 @@ int __init l2x0_of_init(u32 aux_val, u32 aux_mask)
u32 cache_id, old_aux;
u32 cache_level = 2;
bool nosync = false;
+ int ret;
np = of_find_matching_node(NULL, l2x0_ids);
if (!np)
return -ENODEV;
- if (of_address_to_resource(np, 0, &res))
- return -ENODEV;
+ if (of_address_to_resource(np, 0, &res)) {
+ ret = -ENODEV;
+ goto out_put_node;
+ }
l2x0_base = ioremap(res.start, resource_size(&res));
- if (!l2x0_base)
- return -ENOMEM;
+ if (!l2x0_base) {
+ ret = -ENOMEM;
+ goto out_put_node;
+ }
l2x0_saved_regs.phy_base = res.start;
@@ -1821,6 +1826,10 @@ int __init l2x0_of_init(u32 aux_val, u32 aux_mask)
else
cache_id = readl_relaxed(l2x0_base + L2X0_CACHE_ID);
- return __l2c_init(data, aux_val, aux_mask, cache_id, nosync);
+ ret = __l2c_init(data, aux_val, aux_mask, cache_id, nosync);
+
+out_put_node:
+ of_node_put(np);
+ return ret;
}
#endif
--
2.43.0
reply other threads:[~2026-06-08 4:24 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=20260608042331.2633217-1-dbgh9129@gmail.com \
--to=dbgh9129@gmail.com \
--cc=kuninori.morimoto.gx@renesas.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
/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