aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNishka Dasgupta <nishkadg.linux@gmail.com>2019-07-09 22:40:16 +0530
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2020-06-25 15:33:08 +0200
commit09fc51a9fa5264d496ef51c66d33cd8bc305d302 (patch)
tree02d593e2eca9abf47b2d9ea707d91bb27b8e869e
parent3431ad8cd07f8e336e99a17e3882e041674209b8 (diff)
downloadlinux-yocto-09fc51a9fa5264d496ef51c66d33cd8bc305d302.tar.gz
linux-yocto-09fc51a9fa5264d496ef51c66d33cd8bc305d302.tar.bz2
linux-yocto-09fc51a9fa5264d496ef51c66d33cd8bc305d302.zip
mtd: rawnand: oxnas: Add of_node_put()
[ Upstream commit c436f68beeb20f2f92937677db1d9069b0dd2a3d ] 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> Signed-off-by: Sasha Levin <sashal@kernel.org>
-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 5bc180536320..7509bcd96135 100644
--- a/drivers/mtd/nand/raw/oxnas_nand.c
+++ b/drivers/mtd/nand/raw/oxnas_nand.c
@@ -123,7 +123,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;
@@ -144,12 +144,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;
@@ -166,6 +166,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;