arm: mach-versatile: Fix refcount leak bug in tc2_pm
Subsystems (4)
PATCH 1/1 arm: mach-versatile: Fix refcount leak bug in tc2_pm
In tc2_pm_init(), of_find_compatible_node() will return a node pointer with refcount incremented. We should use of_node_put() in fail path or when it is not used anymore.
Signed-off-by Liang He <[email protected]>
--- arch/arm/mach-versatile/tc2_pm.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
arch/arm/mach-versatile/tc2_pm.c +7 -2
@@ -212,19 +212,24 @@ static int __init tc2_pm_init(void) np =of_find_compatible_node (NULL ,NULL ,"arm,vexpress-scc,v2p-ca15_a7" ); scc =of_iomap (np,0 ); -if (!scc) +if (!scc) { +of_node_put (np);return -ENODEV ; + } a15_cluster_id =readl_relaxed (scc +A15_CONF ) &0xf ; a7_cluster_id =readl_relaxed (scc +A7_CONF ) &0xf ; -if (a15_cluster_id >=TC2_CLUSTERS || a7_cluster_id >=TC2_CLUSTERS ) +if (a15_cluster_id >=TC2_CLUSTERS || a7_cluster_id >=TC2_CLUSTERS ) { +of_node_put (np);return -EINVAL ; + } sys_info =readl_relaxed (scc +SYS_INFO ); tc2_nr_cpus[a15_cluster_id] = (sys_info >>16 ) &0xf ; tc2_nr_cpus[a7_cluster_id] = (sys_info >>20 ) &0xf ; irq =irq_of_parse_and_map (np,0 ); +of_node_put (np);/* * A subset of the SCC registers is also used to communicate
Signature · 1 line
2.25.1
Quoted 5 lines · Liang He
In
tc2_pm_init(),of_find_compatible_node()will return a node pointer with refcount incremented. We should useof_node_put()in fail path or when it is not used anymore.Signed-off-by Liang He <[email protected]>
Patch applied.
Yours,
Linus Walleij