]> git.baikalelectronics.ru Git - kernel.git/commitdiff
powerpc/powernv: Add missing of_node_put()s
authorLiang He <windhl@126.com>
Mon, 20 Jun 2022 13:25:53 +0000 (21:25 +0800)
committerMichael Ellerman <mpe@ellerman.id.au>
Mon, 5 Sep 2022 07:30:29 +0000 (17:30 +1000)
In these driver init functions, there are two kinds of errors:

(1) missing of_put_node() for of_find_compatible_node()'s returned
    pointer (refcount incremented)  in fail path or when it is not
    used anymore.
(2) missing of_put_node() for 'for_each_xxx' loop's break

Signed-off-by: Liang He <windhl@126.com>
[mpe: Use out_put_xxx goto label naming]
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20220620132553.4073863-1-windhl@126.com
arch/powerpc/platforms/powernv/idle.c
arch/powerpc/platforms/powernv/opal-core.c
arch/powerpc/platforms/powernv/opal-powercap.c
arch/powerpc/platforms/powernv/opal-psr.c
arch/powerpc/platforms/powernv/opal-sensor-groups.c
arch/powerpc/platforms/powernv/opal.c

index 6e6b3bd9c92ff066d3f273db6aac9aa382751b7f..841cb7f31f4f4d0f17641a2c38e3d2a391d385c3 100644 (file)
@@ -1419,6 +1419,7 @@ out:
        kfree(temp_u32);
        kfree(temp_u64);
        kfree(temp_string);
+       of_node_put(np);
        return rc;
 }
 
index adcb1a1a2bfe805519e1774101ecdc5c5eb913c9..bb7657115f1d276372d53b6edea9be4b89c7ce4b 100644 (file)
@@ -348,6 +348,8 @@ static int __init create_opalcore(void)
        if (!dn || ret)
                pr_warn("WARNING: Failed to read OPAL base & entry values\n");
 
+       of_node_put(dn);
+
        /* Use count to keep track of the program headers */
        count = 0;
 
index 64506b46e77bd16c099dad55948381a798577c3a..7bfe4cbeb35a9934978b384c070d29cb14709c8f 100644 (file)
@@ -153,7 +153,7 @@ void __init opal_powercap_init(void)
        pcaps = kcalloc(of_get_child_count(powercap), sizeof(*pcaps),
                        GFP_KERNEL);
        if (!pcaps)
-               return;
+               goto out_put_powercap;
 
        powercap_kobj = kobject_create_and_add("powercap", opal_kobj);
        if (!powercap_kobj) {
@@ -226,6 +226,7 @@ void __init opal_powercap_init(void)
                }
                i++;
        }
+       of_node_put(powercap);
 
        return;
 
@@ -236,6 +237,9 @@ out_pcaps_pattrs:
                kfree(pcaps[i].pg.name);
        }
        kobject_put(powercap_kobj);
+       of_node_put(node);
 out_pcaps:
        kfree(pcaps);
+out_put_powercap:
+       of_node_put(powercap);
 }
index 69d7e75950d135952d5408f3887ba93eb7746c97..6441e17b699659f2011f733ef8e0708135995cf7 100644 (file)
@@ -135,7 +135,7 @@ void __init opal_psr_init(void)
        psr_attrs = kcalloc(of_get_child_count(psr), sizeof(*psr_attrs),
                            GFP_KERNEL);
        if (!psr_attrs)
-               return;
+               goto out_put_psr;
 
        psr_kobj = kobject_create_and_add("psr", opal_kobj);
        if (!psr_kobj) {
@@ -162,10 +162,14 @@ void __init opal_psr_init(void)
                }
                i++;
        }
+       of_node_put(psr);
 
        return;
 out_kobj:
+       of_node_put(node);
        kobject_put(psr_kobj);
 out:
        kfree(psr_attrs);
+out_put_psr:
+       of_node_put(psr);
 }
index 8fba7d25ae565768d7a7ae386576f353d5af765e..9944376b115c5e367936672ad0aa852d1b324871 100644 (file)
@@ -170,7 +170,7 @@ void __init opal_sensor_groups_init(void)
 
        sgs = kcalloc(of_get_child_count(sg), sizeof(*sgs), GFP_KERNEL);
        if (!sgs)
-               return;
+               goto out_sg_put;
 
        sg_kobj = kobject_create_and_add("sensor_groups", opal_kobj);
        if (!sg_kobj) {
@@ -222,6 +222,7 @@ void __init opal_sensor_groups_init(void)
                }
                i++;
        }
+       of_node_put(sg);
 
        return;
 
@@ -231,6 +232,9 @@ out_sgs_sgattrs:
                kfree(sgs[i].sg.attrs);
        }
        kobject_put(sg_kobj);
+       of_node_put(node);
 out_sgs:
        kfree(sgs);
+out_sg_put:
+       of_node_put(sg);
 }
index 55a8fbfdb5b2874c673eb9dce310fbed5e01be2b..e536a6a3c801704882a123bf9a7830d5a6f79eaf 100644 (file)
@@ -952,6 +952,8 @@ static void __init opal_imc_init_dev(void)
        np = of_find_compatible_node(NULL, NULL, IMC_DTB_COMPAT);
        if (np)
                of_platform_device_create(np, NULL, NULL);
+
+       of_node_put(np);
 }
 
 static int kopald(void *unused)