Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mtd: parsers: ofpart: Fix refcount leak in bcm4908_partitions_fw_offset

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

authored by

Miaoqian Lin and committed by
Miquel Raynal
e607879b 9b78ef0c

+3
+3
drivers/mtd/parsers/ofpart_bcm4908.c
··· 35 35 err = kstrtoul(s + len + 1, 0, &offset); 36 36 if (err) { 37 37 pr_err("failed to parse %s\n", s + len + 1); 38 + of_node_put(root); 38 39 return err; 39 40 } 40 41 42 + of_node_put(root); 41 43 return offset << 10; 42 44 } 43 45 46 + of_node_put(root); 44 47 return -ENOENT; 45 48 } 46 49