All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ARM: vexpress: Fix device_node reference leak in tc2_pm_init()
@ 2026-11-24 15:37 Yuho Choi
  2026-11-30 15:56 ` Sudeep Holla
  0 siblings, 1 reply; 2+ messages 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] 2+ messages in thread

* Re: [PATCH] ARM: vexpress: Fix device_node reference leak in tc2_pm_init()
  2026-11-24 15:37 [PATCH] ARM: vexpress: Fix device_node reference leak in tc2_pm_init() Yuho Choi
@ 2026-11-30 15:56 ` Sudeep Holla
  0 siblings, 0 replies; 2+ messages in thread
From: Sudeep Holla @ 2026-11-30 15:56 UTC (permalink / raw)
  To: Liviu Dudau, Lorenzo Pieralisi, Linus Walleij, Yuho Choi
  Cc: Sudeep Holla, Russell King, Nicolas Pitre, linux-arm-kernel,
	linux-kernel

On Tue, 24 Nov 2026 15:37:35 +0000, Yuho Choi wrote:
> 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.
> 
> [...]

Applied to sudeep.holla/linux (for-next/vexpress/updates), thanks!

[1/1] ARM: vexpress: Fix device_node reference leak in tc2_pm_init()
      https://git.kernel.org/sudeep.holla/c/0cf1a28963b5
-- 
Regards,
Sudeep


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-11-30 15:56 UTC | newest]

Thread overview: 2+ messages (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
2026-11-30 15:56 ` Sudeep Holla

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.