From: Weigang He <geoffreyhe2@gmail.com>
To: Daniel Palmer <daniel@thingy.jp>
Cc: Romain Perier <romain.perier@gmail.com>,
Arnd Bergmann <arnd@arndb.de>,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, Weigang He <geoffreyhe2@gmail.com>
Subject: [PATCH 2/2] ARM: mstar: fix device_node refcount leak in mstarv7_init()
Date: Wed, 10 Jun 2026 15:33:12 +1000 [thread overview]
Message-ID: <20260610053312.2267307-3-geoffreyhe2@gmail.com> (raw)
In-Reply-To: <20260610053312.2267307-1-geoffreyhe2@gmail.com>
of_find_compatible_node() returns a device_node with its refcount
incremented; the caller must drop it with of_node_put() when done.
mstarv7_init() obtains the "mstar,l3bridge" node, maps it with
of_iomap() and never releases the reference, leaking it.
mstarv7_init() is the __init machine init callback, so this leaks one
refcount on the l3bridge node once per boot for the lifetime of the
system.
Drop the reference right after of_iomap(), since np is not used
afterwards.
Found by static analysis tool CodeQL.
Fixes: 312b62b6610c ("ARM: mstar: Add machine for MStar/Sigmastar Armv7 SoCs")
Signed-off-by: Weigang He <geoffreyhe2@gmail.com>
---
arch/arm/mach-mstar/mstarv7.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/arch/arm/mach-mstar/mstarv7.c b/arch/arm/mach-mstar/mstarv7.c
index 871c0fd258e66..64262b8f10a0c 100644
--- a/arch/arm/mach-mstar/mstarv7.c
+++ b/arch/arm/mach-mstar/mstarv7.c
@@ -117,6 +117,7 @@ static void __init mstarv7_init(void)
np = of_find_compatible_node(NULL, NULL, "mstar,l3bridge");
l3bridge = of_iomap(np, 0);
+ of_node_put(np);
if (l3bridge)
soc_mb = mstarv7_mb;
else
--
2.43.0
next prev parent reply other threads:[~2026-06-10 5:33 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-10 5:33 [PATCH 0/2] ARM: mstar: fix two device_node refcount leaks in mstarv7.c Weigang He
2026-06-10 5:33 ` [PATCH 1/2] ARM: mstar: fix device_node refcount leak in mstarv7_boot_secondary() Weigang He
2026-06-10 5:33 ` Weigang He [this message]
2026-06-10 8:45 ` [PATCH 0/2] ARM: mstar: fix two device_node refcount leaks in mstarv7.c Daniel Palmer
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=20260610053312.2267307-3-geoffreyhe2@gmail.com \
--to=geoffreyhe2@gmail.com \
--cc=arnd@arndb.de \
--cc=daniel@thingy.jp \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=romain.perier@gmail.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