Skip to contentSkip to conversation

mtd: partitions: Fix refcount leak in parse_redboot_of

PATCH Applied Miaoqian Lin 3 participants 3 messages May 26, 2022 – Jun 9, 2022 Memory technology devices (MTD)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mtd: partitions: Fix refcount leak in parse_redboot_of

of_get_child_by_name() 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 237960880960 ("mtd: partitions: redboot: seek fis-index-block in the right node")
---
 drivers/mtd/parsers/redboot.c | 1 +
 1 file changed, 1 insertion(+)
drivers/mtd/parsers/redboot.c +1 -0
index feb44a573d44..a16b42a88581 100644
@@ -58,6 +58,7 @@ static void parse_redboot_of(struct mtd_info *master)
 		return;
 
 	ret = of_property_read_u32(npart, "fis-index-block", &dirblock);
+	of_node_put(npart);
 	if (ret)
 		return;
 
Signature · 1 line
2.25.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 6 lines · Miaoqian Lin

of_get_child_by_name() 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 237960880960 ("mtd: partitions: redboot: seek fis-index-block in the right node")

Yours,
Linus Walleij

maintainer Applied
#2 lore raw
In reply to Miaoqian Lin
Quoted 7 lines · Miaoqian Lin

of_get_child_by_name() 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 237960880960 ("mtd: partitions: redboot: seek fis-index-block in the right node")

Applied to https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git mtd/next, thanks.

Miquel