* [PATCH] ARM: vexpress: Fix device_node reference leak in tc2_pm_init()
@ 2026-11-24 15:37 Yuho Choi
0 siblings, 0 replies; only message in thread
From: Yuho Choi @ 2026-11-24 15:37 UTC (permalink / raw)
To: Sudeep Holla, Liviu Dudau, Lorenzo Pieralisi, Linus Walleij
Cc: Russell King, Nicolas Pitre, linux-arm-kernel, linux-kernel,
Yuho Choi
tc2_pm_init() looks up the SCC node with of_find_compatible_node(),
which returns the node with its reference count raised, and passes it
to of_iomap() and irq_of_parse_and_map(). Neither of them keeps the
node, and none of the function's exits drops the reference.
tc2_pm_init() runs once as an early initcall, so this leaks a single
reference at boot.
Declare np with __free(device_node) so that the reference is dropped
when the function returns, as is already done in vexpress_flags_set()
and vexpress_smp_dt_prepare_cpus().
Fixes: 11b277eabe70 ("ARM: vexpress/TC2: basic PM support")
Signed-off-by: Yuho Choi <oss.patchbox@gmail.com>
---
Compile-tested only (ARM multi_v7_defconfig, W=1). I have no TC2 board
to test it on.
arch/arm/mach-versatile/tc2_pm.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/arch/arm/mach-versatile/tc2_pm.c b/arch/arm/mach-versatile/tc2_pm.c
index 0fe78da0c109..0e471a76bc98 100644
--- a/arch/arm/mach-versatile/tc2_pm.c
+++ b/arch/arm/mach-versatile/tc2_pm.c
@@ -202,15 +202,15 @@ static int __init tc2_pm_init(void)
unsigned int mpidr, cpu, cluster;
int ret, irq;
u32 a15_cluster_id, a7_cluster_id, sys_info;
- struct device_node *np;
/*
* The power management-related features are hidden behind
* SCC registers. We need to extract runtime information like
* cluster ids and number of CPUs really available in clusters.
*/
- np = of_find_compatible_node(NULL, NULL,
- "arm,vexpress-scc,v2p-ca15_a7");
+ struct device_node *np __free(device_node) =
+ of_find_compatible_node(NULL, NULL,
+ "arm,vexpress-scc,v2p-ca15_a7");
scc = of_iomap(np, 0);
if (!scc)
return -ENODEV;
base-commit: 8dac6df92a2e66e2098bbc69061964cfe7e8375b
--
2.56.1
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2026-11-24 16:09 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-24 15:37 [PATCH] ARM: vexpress: Fix device_node reference leak in tc2_pm_init() Yuho Choi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox