mips/pic32/pic32mzda: Fix refcount leak bugs
PATCH v2 1/1 mips/pic32/pic32mzda: Fix refcount leak bugs
of_find_matching_node(), of_find_compatible_node() and of_find_node_by_path() will return node pointers with refcout incremented. We should call of_node_put() when they are not used anymore.
---
changelog:
v2: (1) merge pic32/pic32mzda bugs into one patch
(2) fix leak bug related to of_find_node_by_path.
v1: use two patch for intit.c and time.c
arch/mips/pic32/pic32mzda/init.c | 7 ++++++- arch/mips/pic32/pic32mzda/time.c | 3 +++ 2 files changed, 9 insertions(+), 1 deletion(-)
arch/mips/pic32/pic32mzda/init.c +6 -1
@@ -98,13 +98,18 @@ static int __init pic32_of_prepare_platform_data(struct of_dev_auxdata *lookup) np =of_find_compatible_node (NULL ,NULL , lookup->compatible);if (np) { lookup->name = (char *)np->name; -if (lookup->phys_addr) +if (lookup->phys_addr) { +of_node_put (np);continue ; + }if (!of_address_to_resource (np,0 , &res)) lookup->phys_addr = res.start; +of_node_put (np); } } +of_node_put (root); +return 0 ; }
arch/mips/pic32/pic32mzda/time.c +3 -0
@@ -32,6 +32,9 @@ static unsigned int pic32_xlate_core_timer_irq(void) goto default_map; irq =irq_of_parse_and_map (node,0 ); + +of_node_put (node); +if (!irq) goto default_map;
Signature · 1 line
2.25.1
Quoted 9 lines · Liang He
of_find_matching_node(),of_find_compatible_node()andof_find_node_by_path()will return node pointers with refcout incremented. We should callof_node_put()when they are not used anymore.Signed-off-by Liang He <[email protected]>---
changelog:
Quoted 7 lines
v2: (1) merge pic32/pic32mzda bugs into one patch
(2) fix leak bug related toof_find_node_by_path.
v1: use two patch forintit.candtime.carch/mips/pic32/pic32mzda/init.c | 7 ++++++- arch/mips/pic32/pic32mzda/time.c | 3 +++ 2 files changed, 9 insertions(+), 1 deletion(-)
applied to mips-fixes.
Thomas.
Signature · 2 lines
Crap can work. Given enough thrust pigs will fly, but it's not necessarily a good idea. [ RFC1925, 2.3 ]