ARM: vexpress: Fix device_node reference leak in tc2_pm_init()
Subsystems (4)
PATCH 1/1 ARM: vexpress: Fix device_node reference leak in tc2_pm_init()
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 <[email protected]>
---
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(-)
arch/arm/mach-versatile/tc2_pm.c +3 -3
@@ -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
Signature · 1 line
2.56.1