Skip to contentSkip to conversation

mtd: maps: Fix refcount leak in ap_flash_init

PATCH Applied Miaoqian Lin 3 participants 3 messages May 23, 2022 – Jun 9, 2022

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mtd: maps: Fix refcount leak in ap_flash_init

of_find_matching_node() 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 b0afd44bc192 ("mtd: physmap_of: add a hook for Versatile write protection")
---
 drivers/mtd/maps/physmap-versatile.c | 1 +
 1 file changed, 1 insertion(+)
drivers/mtd/maps/physmap-versatile.c +1 -0
index ad7cd9cfaee0..6ba6a1dd127c 100644
@@ -93,6 +93,7 @@ static int ap_flash_init(struct platform_device *pdev)
 		return -ENODEV;
 	}
 	ebi_base = of_iomap(ebi, 0);
+	of_node_put(ebi);
 	if (!ebi_base)
 		return -ENODEV;
 
Signature · 1 line
2.25.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 6 lines · Miaoqian Lin

of_find_matching_node() 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 b0afd44bc192 ("mtd: physmap_of: add a hook for Versatile write protection")

Yours,
Linus Walleij

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

of_find_matching_node() 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 b0afd44bc192 ("mtd: physmap_of: add a hook for Versatile write protection")

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

Miquel