summaryrefslogtreecommitdiffstats
path: root/drivers/mtd/nand/raw
diff options
context:
space:
mode:
authorNishka Dasgupta <nishkadg.linux@gmail.com>2019-07-09 19:10:16 +0200
committerMiquel Raynal <miquel.raynal@bootlin.com>2019-07-25 14:21:44 +0200
commitc436f68beeb20f2f92937677db1d9069b0dd2a3d (patch)
treee3f28c61259c14331eb2f152a2a7261e9fc01746 /drivers/mtd/nand/raw
parentmtd: rawnand: vf610: Add of_node_put() before goto (diff)
downloadlinux-c436f68beeb20f2f92937677db1d9069b0dd2a3d.tar.xz
linux-c436f68beeb20f2f92937677db1d9069b0dd2a3d.zip
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. Signed-off-by: Nishka Dasgupta <nishkadg.linux@gmail.com> Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Diffstat (limited to 'drivers/mtd/nand/raw')
-rw-r--r--drivers/mtd/nand/raw/oxnas_nand.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/drivers/mtd/nand/raw/oxnas_nand.c b/drivers/mtd/nand/raw/oxnas_nand.c
index 30c51f772de6..c43cb4d92d3d 100644
--- a/drivers/mtd/nand/raw/oxnas_nand.c
+++ b/drivers/mtd/nand/raw/oxnas_nand.c
@@ -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;