]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
mips/pic32/pic32mzda: Fix refcount leak bugs
authorLiang He <windhl@126.com>
Sun, 19 Jun 2022 04:54:27 +0000 (12:54 +0800)
committerThomas Bogendoerfer <tsbogend@alpha.franken.de>
Tue, 21 Jun 2022 15:04:54 +0000 (17:04 +0200)
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>
arch/mips/pic32/pic32mzda/init.c
arch/mips/pic32/pic32mzda/time.c

index 129915616763ac18e8c7e9e5c7be81061fe71439..d9c8c4e46aff99e1b86ba734a9a57f3522bec43d 100644 (file)
@@ -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;
 }
 
index 7174e9abbb1ba891c51cea9f7858175eb3ecbd00..777b515c52c8da635f18eb0601d530b1af6d3cbf 100644 (file)
@@ -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;