MIPS: Loongson64: Add missing of_node_put() in ls2k_reset_init()
authorYang Yingliang <yangyingliang@huawei.com>
Tue, 4 Jan 2022 13:34:15 +0000 (21:34 +0800)
committerThomas Bogendoerfer <tsbogend@alpha.franken.de>
Wed, 5 Jan 2022 08:53:45 +0000 (09:53 +0100)
This node pointer is returned by of_find_compatible_node() with
refcount incremented in ls2k_reset_init(). Calling of_node_put()
to aovid the refcount leak.

Fixes: 7eb7819a2e12 ("MIPS: Loongson64: Add Loongson-2K1000 reset platform driver")
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
drivers/platform/mips/ls2k-reset.c

index b70e7b8..8f42d5d 100644 (file)
@@ -38,6 +38,7 @@ static int ls2k_reset_init(void)
        }
 
        base = of_iomap(np, 0);
+       of_node_put(np);
        if (!base) {
                pr_info("Failed to map PM register base address\n");
                return -ENOMEM;
@@ -46,7 +47,6 @@ static int ls2k_reset_init(void)
        _machine_restart = ls2k_restart;
        pm_power_off = ls2k_poweroff;
 
-       of_node_put(np);
        return 0;
 }