mtd: rawnand: oxnas: Add of_node_put()
Subsystems (2)
PATCH 1/1 mtd: rawnand: oxnas: Add of_node_put()
Each iteration of for_each_child_of_node puts the previous node, but in the case of a goto from the middle of the loop, there is no put, thus causing a memory leak. Hence add an of_node_put under a new goto to put the node at a loop exit.
Issue found with Coccinelle.
--- drivers/mtd/nand/raw/oxnas_nand.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/mtd/nand/raw/oxnas_nand.c +5 -3
@@ -116,7 +116,7 @@ static int oxnas_nand_probe(struct platform_device *pdev) GFP_KERNEL);if (!chip) { err = -ENOMEM ; - goto err_clk_unprepare; + goto err_release_child; } chip->controller = &oxnas->base;
@@ -137,12 +137,12 @@ static int oxnas_nand_probe(struct platform_device *pdev)/* Scan to find existence of the device */ err =nand_scan (chip,1 );if (err) - goto err_clk_unprepare; + goto err_release_child; err =mtd_device_register (mtd,NULL ,0 );if (err) {nand_release (chip); - goto err_clk_unprepare; + goto err_release_child; } oxnas->chips[nchips] = chip;
@@ -159,6 +159,8 @@ static int oxnas_nand_probe(struct platform_device *pdev)return 0 ; +err_release_child: +of_node_put (nand_np); err_clk_unprepare:clk_disable_unprepare (oxnas->clk);return err;
Signature · 6 lines
2.19.1 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/
Quoted 7 lines · Nishka Dasgupta
Each iteration of
for_each_child_of_nodeputs the previous node, but in the case of a goto from the middle of the loop, there is no put, thus causing a memory leak. Hence add anof_node_putunder a new goto to put the node at a loop exit.
Issue found with Coccinelle.Signed-off-by Nishka Dasgupta <[email protected]>
Applied to https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git nand/next, thanks.
Miquel
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/