public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Yuho Choi <dbgh9129@gmail.com>
To: Russell King <linux@armlinux.org.uk>, Nishanth Menon <nm@ti.com>
Cc: Lee Jones <lee@kernel.org>, Kees Cook <kees@kernel.org>,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, Yuho Choi <dbgh9129@gmail.com>
Subject: [PATCH v1] ARM: Feroceon: Fix OF node and mapping leaks in L2 init
Date: Mon,  4 May 2026 20:32:52 -0400	[thread overview]
Message-ID: <20260505003252.2886028-1-dbgh9129@gmail.com> (raw)

of_find_matching_node() returns a referenced device node, and of_iomap()
creates a temporary mapping. feroceon_of_init() currently leaves both
resources around after init and also returns from the of_iomap() failure
path without dropping the node reference.

Unmap the register mapping after the register update and put the node on
both the failure and success paths.

Fixes: 4b8f7a11c9fb ("ARM: MM: Add DT binding for Feroceon L2 cache")
Signed-off-by: Yuho Choi <dbgh9129@gmail.com>
---
 arch/arm/mm/cache-feroceon-l2.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/arch/arm/mm/cache-feroceon-l2.c b/arch/arm/mm/cache-feroceon-l2.c
index 2bfefb252ffd..1fe931a09d79 100644
--- a/arch/arm/mm/cache-feroceon-l2.c
+++ b/arch/arm/mm/cache-feroceon-l2.c
@@ -373,16 +373,20 @@ int __init feroceon_of_init(void)
 	node = of_find_matching_node(NULL, feroceon_ids);
 	if (node && of_device_is_compatible(node, "marvell,kirkwood-cache")) {
 		base = of_iomap(node, 0);
-		if (!base)
+		if (!base) {
+			of_node_put(node);
 			return -ENOMEM;
+		}
 
 		if (l2_wt_override)
 			writel(readl(base) | L2_WRITETHROUGH_KIRKWOOD, base);
 		else
 			writel(readl(base) & ~L2_WRITETHROUGH_KIRKWOOD, base);
+		iounmap(base);
 	}
 
 	feroceon_l2_init(l2_wt_override);
+	of_node_put(node);
 
 	return 0;
 }
-- 
2.43.0


                 reply	other threads:[~2026-05-05  0:32 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=20260505003252.2886028-1-dbgh9129@gmail.com \
    --to=dbgh9129@gmail.com \
    --cc=kees@kernel.org \
    --cc=lee@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=nm@ti.com \
    /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