* [PATCH] mtd: rawnand: tango: Add of_node_put() before return
@ 2019-07-09 17:13 Nishka Dasgupta
2019-07-09 18:42 ` Måns Rullgård
2019-07-25 7:55 ` Miquel Raynal
0 siblings, 2 replies; 3+ messages in thread
From: Nishka Dasgupta @ 2019-07-09 17:13 UTC (permalink / raw)
To: miquel.raynal, richard, dwmw2, computersforpeace, marek.vasut,
vigneshr, linux-mtd, marc.w.gonzalez, mans
Cc: Nishka Dasgupta
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.
Signed-off-by: Nishka Dasgupta <nishkadg.linux@gmail.com>
---
drivers/mtd/nand/raw/tango_nand.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/mtd/nand/raw/tango_nand.c b/drivers/mtd/nand/raw/tango_nand.c
index b3f2cabcc7c0..9acf2de37ee0 100644
--- a/drivers/mtd/nand/raw/tango_nand.c
+++ b/drivers/mtd/nand/raw/tango_nand.c
@@ -659,6 +659,7 @@ static int tango_nand_probe(struct platform_device *pdev)
err = chip_init(&pdev->dev, np);
if (err) {
tango_nand_remove(pdev);
+ of_node_put(np);
return err;
}
}
--
2.19.1
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] mtd: rawnand: tango: Add of_node_put() before return
2019-07-09 17:13 [PATCH] mtd: rawnand: tango: Add of_node_put() before return Nishka Dasgupta
@ 2019-07-09 18:42 ` Måns Rullgård
2019-07-25 7:55 ` Miquel Raynal
1 sibling, 0 replies; 3+ messages in thread
From: Måns Rullgård @ 2019-07-09 18:42 UTC (permalink / raw)
To: Nishka Dasgupta
Cc: vigneshr, marc.w.gonzalez, richard, marek.vasut, linux-mtd,
miquel.raynal, computersforpeace, dwmw2
Nishka Dasgupta <nishkadg.linux@gmail.com> writes:
> 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.
>
> Signed-off-by: Nishka Dasgupta <nishkadg.linux@gmail.com>
> ---
> drivers/mtd/nand/raw/tango_nand.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/drivers/mtd/nand/raw/tango_nand.c b/drivers/mtd/nand/raw/tango_nand.c
> index b3f2cabcc7c0..9acf2de37ee0 100644
> --- a/drivers/mtd/nand/raw/tango_nand.c
> +++ b/drivers/mtd/nand/raw/tango_nand.c
> @@ -659,6 +659,7 @@ static int tango_nand_probe(struct platform_device *pdev)
> err = chip_init(&pdev->dev, np);
> if (err) {
> tango_nand_remove(pdev);
> + of_node_put(np);
> return err;
> }
> }
> --
Acked-by: Mans Rullgard <mans@mansr.com>
--
Måns Rullgård
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] mtd: rawnand: tango: Add of_node_put() before return
2019-07-09 17:13 [PATCH] mtd: rawnand: tango: Add of_node_put() before return Nishka Dasgupta
2019-07-09 18:42 ` Måns Rullgård
@ 2019-07-25 7:55 ` Miquel Raynal
1 sibling, 0 replies; 3+ messages in thread
From: Miquel Raynal @ 2019-07-25 7:55 UTC (permalink / raw)
To: Nishka Dasgupta, miquel.raynal, richard, dwmw2,
computersforpeace, marek.vasut, vigneshr, linux-mtd,
marc.w.gonzalez, mans
On Tue, 2019-07-09 at 17:13:16 UTC, Nishka Dasgupta wrote:
> 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.
>
> Signed-off-by: Nishka Dasgupta <nishkadg.linux@gmail.com>
> Acked-by: Mans Rullgard <mans@mansr.com>
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/
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-07-25 7:56 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-09 17:13 [PATCH] mtd: rawnand: tango: Add of_node_put() before return Nishka Dasgupta
2019-07-09 18:42 ` Måns Rullgård
2019-07-25 7:55 ` Miquel Raynal
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).