[PATCH] ARM: vexpress: fix iounmap missing after of_iomap in SMP prepare

Sudeep Holla sudeep.holla at kernel.org
Wed Nov 4 06:54:45 PST 2026


of_iomap() maps a region of device memory and returns a pointer that
must later be released with iounmap(). Currently return value from
of_iomap() is passed directly to scu_enable() without saving it, making
it impossible to unmap afterwards, causing an I/O memory leak.

Store the mapped base address in a local variable, check it for NULL,
call scu_enable(), then release the mapping with iounmap().

Reported-by: Sashiko <sashiko-bot at kernel.org>
Closes: https://sashiko.dev/#/bug/linux-5bb0baa3-6a9a-49a0-94f1-80f8cd8f6915
Closes: https://sashiko.dev/#/bug/linux-6803acf3-f91e-450a-a738-8803e6ac1f1a
Signed-off-by: Sudeep Holla <sudeep.holla at kernel.org>
---
 arch/arm/mach-versatile/platsmp-vexpress.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mach-versatile/platsmp-vexpress.c b/arch/arm/mach-versatile/platsmp-vexpress.c
index b810ad50b98c..e3c8ee4c52fb 100644
--- a/arch/arm/mach-versatile/platsmp-vexpress.c
+++ b/arch/arm/mach-versatile/platsmp-vexpress.c
@@ -63,9 +63,15 @@ static void __init vexpress_smp_dt_prepare_cpus(unsigned int max_cpus)
 {
 	struct device_node *scu __free(device_node) =
 		of_find_matching_node(NULL, vexpress_smp_dt_scu_match);
+	void __iomem *scu_base;
 
-	if (scu)
-		scu_enable(of_iomap(scu, 0));
+	if (scu) {
+		scu_base = of_iomap(scu, 0);
+		if (scu_base) {
+			scu_enable(scu_base);
+			iounmap(scu_base);
+		}
+	}
 
 	/*
 	 * Write the address of secondary startup into the
-- 
2.43.0




More information about the linux-arm-kernel mailing list