ARM: socfpga: Fix OF node refcount leak in SMP setup
Subsystems (3)
PATCH 1/1 ARM: socfpga: Fix OF node refcount leak in SMP setup
socfpga_smp_prepare_cpus() looks up the Cortex-A9 SCU node with of_find_compatible_node(), which returns a node reference that must be released with of_node_put().
The function maps the SCU registers and then returns without dropping that reference, leaking the node on both the success path and the of_iomap() failure path.
Drop the reference once the mapping attempt is complete. The returned MMIO mapping does not depend on keeping the device node reference held.
--- arch/arm/mach-socfpga/platsmp.c | 1 + 1 file changed, 1 insertion(+)
arch/arm/mach-socfpga/platsmp.c +1 -0
@@ -78,6 +78,7 @@ static void __init socfpga_smp_prepare_cpus(unsigned int max_cpus) } socfpga_scu_base_addr =of_iomap (np,0 ); +of_node_put (np);if (!socfpga_scu_base_addr)return ;scu_enable (socfpga_scu_base_addr);
Signature · 1 line
2.43.0
Dinh Nguyen
maintainerHi Yuho,
Quoted 8 lines · Yuho Choi
socfpga_smp_prepare_cpus()looks up the Cortex-A9 SCU node withof_find_compatible_node(), which returns a node reference that must be released withof_node_put().The function maps the SCU registers and then returns without dropping that reference, leaking the node on both the success path and the
of_iomap()failure path.
Quoted 5 lines
Drop the reference once the mapping attempt is complete. The returned MMIO mapping does not depend on keeping the device node reference held.
Fixes 122694a0c712 ("ARM: socfpga: use of_iomap to map the SCU")Signed-off-by Yuho Choi <[email protected]>
I'll add "Cc: [email protected]" here, but please remember to add this for future patches that have the Fixes tag.
Thanks,
Dinh