csky: fix refcount leak in setup_smp()
PATCH 1/1 csky: fix refcount leak in setup_smp()
The of_find_node_by_type() returns a node pointer with refcount incremented, but there is the lack of use of the of_node_put() when done. Add the missing of_node_put() to release the refcount.
Signed-off-by Yangtao Li <[email protected]>
--- arch/csky/kernel/smp.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
arch/csky/kernel/smp.c +8 -2
@@ -139,11 +139,17 @@ void __init setup_smp(void)int cpu;while ((node =of_find_node_by_type (node,"cpu" ))) { -if (!of_device_is_available (node)) +if (!of_device_is_available (node)) { +of_node_put (node);continue ; + } -if (of_property_read_u32 (node,"reg" , &cpu)) +if (of_property_read_u32 (node,"reg" , &cpu)) { +of_node_put (node);continue ; + } + +of_node_put (node);if (cpu >=NR_CPUS )continue ;
Signature · 1 line
2.17.0
Guo Ren
maintainerHi Li,
Quoted 20 lines · Yangtao Li
The
of_find_node_by_type()returns a node pointer with refcount incremented, but there is the lack of use of theof_node_put()when done. Add the missingof_node_put()to release the refcount.Signed-off-by Yangtao Li <[email protected]>--- arch/csky/kernel/smp.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)arch/csky/kernel/smp.c +2
-1@@ -139,11 +139,17 @@ void __init setup_smp(void)int cpu;while ((node =of_find_node_by_type (node,"cpu" ))) { -if (!of_device_is_available (node)) +if (!of_device_is_available (node)) { +of_node_put (node);
arch/csky/kernel/smp.c void __init setup_smp(void) · line 152
Quoted 10 lines
arch/csky/kernel/smp.c +6
-1continue ; + } -if (of_property_read_u32 (node,"reg" , &cpu)) +if (of_property_read_u32 (node,"reg" , &cpu)) { +of_node_put (node);continue ; + } + +of_node_put (node);
If success, of_node_put ?
arch/csky/kernel/smp.c void __init setup_smp(void) · line 154
Quoted 2 lines
arch/csky/kernel/smp.c +0
-0if (cpu >=NR_CPUS )
Here need a of_node_put()?
arch/csky/kernel/smp.c void __init setup_smp(void) · line 154
Quoted 1 line
arch/csky/kernel/smp.c +0
-0continue ;
Can you use for_each_of_cpu_node() for the patch?
Thx
Guo Ren