mtd: rawnand: meson: Add of_node_put() before return
Subsystems (4)
PATCH 1/1 mtd: rawnand: meson: Add of_node_put() before return
Each iteration of for_each_child_of_node puts the previous node, but in the case of a return from the middle of the loop, there is no put, thus causing a memory leak. Hence add an of_node_put before the return. Issue found with Coccinelle.
--- drivers/mtd/nand/raw/meson_nand.c | 1 + 1 file changed, 1 insertion(+)
drivers/mtd/nand/raw/meson_nand.c +1 -0
@@ -1320,6 +1320,7 @@ static int meson_nfc_nand_chips_init(struct device *dev, ret =meson_nfc_nand_chip_init (dev, nfc, nand_np);if (ret) {meson_nfc_nand_chip_cleanup (nfc); +of_node_put (nand_np);return ret; } }
Signature · 6 lines
2.19.1 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/
Hi Nishka,
Quoted 15 lines · Nishka Dasgupta
Each iteration of
for_each_child_of_nodeputs the previous node, but in the case of a return from the middle of the loop, there is no put, thus causing a memory leak. Hence add anof_node_putbefore the return. Issue found with Coccinelle.Signed-off-by Nishka Dasgupta <[email protected]>--- drivers/mtd/nand/raw/meson_nand.c | 1 + 1 file changed, 1 insertion(+)drivers/mtd/nand/raw/meson_nand.c +0
-0
drivers/mtd/nand/raw/meson_nand.c static int meson_nfc_nand_chips_init(struct device *dev, · line 1323
Quoted 4 lines
drivers/mtd/nand/raw/meson_nand.c +1
-0@@ -1320,6 +1320,7 @@ static int meson_nfc_nand_chips_init(struct device *dev, ret =meson_nfc_nand_chip_init (dev, nfc, nand_np);if (ret) {meson_nfc_nand_chip_cleanup (nfc); +of_node_put (nand_np);
Thank you. Looks good to me:
drivers/mtd/nand/raw/meson_nand.c static int meson_nfc_nand_chips_init(struct device *dev, · line 1326
Quoted 4 lines
drivers/mtd/nand/raw/meson_nand.c +0
-0return ret; } }
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Quoted 7 lines · Nishka Dasgupta
Each iteration of
for_each_child_of_nodeputs the previous node, but in the case of a return from the middle of the loop, there is no put, thus causing a memory leak. Hence add anof_node_putbefore the return. Issue found with Coccinelle.Signed-off-by Nishka Dasgupta <[email protected]>Acked-by Liang Yang <[email protected]>
Applied to https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git nand/next, thanks.
Miquel
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel