Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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.

Signed-off-by: Liang He <windhl@126.com>
Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>

authored by

Liang He and committed by
Thomas Bogendoerfer
eb9e9bc4 76695592

+9 -1
+6 -1
arch/mips/pic32/pic32mzda/init.c
··· 98 98 np = of_find_compatible_node(NULL, NULL, lookup->compatible); 99 99 if (np) { 100 100 lookup->name = (char *)np->name; 101 - if (lookup->phys_addr) 101 + if (lookup->phys_addr) { 102 + of_node_put(np); 102 103 continue; 104 + } 103 105 if (!of_address_to_resource(np, 0, &res)) 104 106 lookup->phys_addr = res.start; 107 + of_node_put(np); 105 108 } 106 109 } 110 + 111 + of_node_put(root); 107 112 108 113 return 0; 109 114 }
+3
arch/mips/pic32/pic32mzda/time.c
··· 32 32 goto default_map; 33 33 34 34 irq = irq_of_parse_and_map(node, 0); 35 + 36 + of_node_put(node); 37 + 35 38 if (!irq) 36 39 goto default_map; 37 40