mtd: parsers: ofpart: Fix refcount leak in bcm4908_partitions_fw_offset
authorMiaoqian Lin <linmq006@gmail.com>
Sun, 5 Jun 2022 07:07:23 +0000 (11:07 +0400)
committerMiquel Raynal <miquel.raynal@bootlin.com>
Thu, 9 Jun 2022 13:03:32 +0000 (15:03 +0200)
of_find_node_by_path() returns a node pointer with refcount incremented,
we should use of_node_put() on it when not need anymore.
Add missing of_node_put() to avoid refcount leak.

Fixes: bb17230c61a6 ("mtd: parsers: ofpart: support BCM4908 fixed partitions")
Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20220605070726.5979-1-linmq006@gmail.com
drivers/mtd/parsers/ofpart_bcm4908.c

index 0eddef4c198eccc9be8ae67f45d48d22b6dbb923..bb072a0940e480112211505f12534d4b6d5d915f 100644 (file)
@@ -35,12 +35,15 @@ static long long bcm4908_partitions_fw_offset(void)
                err = kstrtoul(s + len + 1, 0, &offset);
                if (err) {
                        pr_err("failed to parse %s\n", s + len + 1);
+                       of_node_put(root);
                        return err;
                }
 
+               of_node_put(root);
                return offset << 10;
        }
 
+       of_node_put(root);
        return -ENOENT;
 }