ARM: shmobile: rcar-gen2: Add missing of_node_put()
authorWan Jiabing <wanjiabing@vivo.com>
Mon, 18 Oct 2021 01:45:03 +0000 (21:45 -0400)
committerGeert Uytterhoeven <geert+renesas@glider.be>
Mon, 15 Nov 2021 08:58:53 +0000 (09:58 +0100)
Fix following coccicheck warning:
./arch/arm/mach-shmobile/regulator-quirk-rcar-gen2.c:156:1-33: Function
for_each_matching_node_and_match should have of_node_put() before break
and goto.

Early exits from for_each_matching_node_and_match() should decrement the
node reference counter.

Signed-off-by: Wan Jiabing <wanjiabing@vivo.com>
Link: https://lore.kernel.org/r/20211018014503.7598-1-wanjiabing@vivo.com
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
arch/arm/mach-shmobile/regulator-quirk-rcar-gen2.c

index ee94925..09ef73b 100644 (file)
@@ -154,8 +154,10 @@ static int __init rcar_gen2_regulator_quirk(void)
                return -ENODEV;
 
        for_each_matching_node_and_match(np, rcar_gen2_quirk_match, &id) {
-               if (!of_device_is_available(np))
+               if (!of_device_is_available(np)) {
+                       of_node_put(np);
                        break;
+               }
 
                ret = of_property_read_u32(np, "reg", &addr);
                if (ret)        /* Skip invalid entry and continue */
@@ -164,6 +166,7 @@ static int __init rcar_gen2_regulator_quirk(void)
                quirk = kzalloc(sizeof(*quirk), GFP_KERNEL);
                if (!quirk) {
                        ret = -ENOMEM;
+                       of_node_put(np);
                        goto err_mem;
                }