[PATCH 2/2] ARM: mstar: fix device_node refcount leak in mstarv7_init()
Weigang He
geoffreyhe2 at gmail.com
Tue Jun 9 22:33:12 PDT 2026
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 at 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
More information about the linux-arm-kernel
mailing list