History

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.

Liang He committed 4 years ago

Commit eb9e9bc1 parent 76695592 files · +9 −1Browse files

Unified · Split

2 files
  1. arch/mips/pic32/pic32mzda/init.c +6 −1
  2. arch/mips/pic32/pic32mzda/time.c +3 −0
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) · 97 unmodified lines
9898 np = of_find_compatible_node(NULL, NULL, lookup->compatible);
9999 if (np) {
100100 lookup->name = (char *)np->name;
101− if (lookup->phys_addr)
101+ if (lookup->phys_addr) {
102+ of_node_put(np);
102103 continue;
104+ }
103105 if (!of_address_to_resource(np, 0, &res))
104106 lookup->phys_addr = res.start;
107+ of_node_put(np);
105108 }
106109 }
107110
111+ of_node_put(root);
112+
108113 return 0;
109114 }
110115
arch/mips/pic32/pic32mzda/time.c+3−0
@@ -32,6 +32,9 @@ static unsigned int pic32_xlate_core_timer_irq(void) · 31 unmodified lines
3232 goto default_map;
3333
3434 irq = irq_of_parse_and_map(node, 0);
35+
36+ of_node_put(node);
37+
3538 if (!irq)
3639 goto default_map;
3740