* [PATCH] mtd: spi-nor: hisi-sfc: Add of_node_put() before break
@ 2019-08-15 6:03 Nishka Dasgupta
2019-08-28 10:21 ` Tudor.Ambarus
0 siblings, 1 reply; 2+ messages in thread
From: Nishka Dasgupta @ 2019-08-15 6:03 UTC (permalink / raw)
To: marek.vasut, tudor.ambarus, dwmw2, computersforpeace,
miquel.raynal, richard, vigneshr, linux-mtd
Cc: Nishka Dasgupta
Each iteration of for_each_available_child_of_node puts the previous
node, but in the case of a break from the middle of the loop, there
is no put, thus causing a memory leak. Hence add an of_node_put before
the break.
Issue found with Coccinelle.
Signed-off-by: Nishka Dasgupta <nishkadg.linux@gmail.com>
---
drivers/mtd/spi-nor/hisi-sfc.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/mtd/spi-nor/hisi-sfc.c b/drivers/mtd/spi-nor/hisi-sfc.c
index dea43ea3eea3..6dac9dd8bf42 100644
--- a/drivers/mtd/spi-nor/hisi-sfc.c
+++ b/drivers/mtd/spi-nor/hisi-sfc.c
@@ -401,6 +401,7 @@ static int hisi_spi_nor_register_all(struct hifmc_host *host)
if (host->num_chip == HIFMC_MAX_CHIP_NUM) {
dev_warn(dev, "Flash device number exceeds the maximum chipselect number\n");
+ of_node_put(np);
break;
}
}
--
2.19.1
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] mtd: spi-nor: hisi-sfc: Add of_node_put() before break
2019-08-15 6:03 [PATCH] mtd: spi-nor: hisi-sfc: Add of_node_put() before break Nishka Dasgupta
@ 2019-08-28 10:21 ` Tudor.Ambarus
0 siblings, 0 replies; 2+ messages in thread
From: Tudor.Ambarus @ 2019-08-28 10:21 UTC (permalink / raw)
To: nishkadg.linux, marek.vasut, dwmw2, computersforpeace,
miquel.raynal, richard, vigneshr, linux-mtd
On 08/15/2019 09:03 AM, Nishka Dasgupta wrote:
> External E-Mail
>
>
> Each iteration of for_each_available_child_of_node puts the previous
> node, but in the case of a break from the middle of the loop, there
> is no put, thus causing a memory leak. Hence add an of_node_put before
> the break.
> Issue found with Coccinelle.
>
> Signed-off-by: Nishka Dasgupta <nishkadg.linux@gmail.com>
> ---
> drivers/mtd/spi-nor/hisi-sfc.c | 1 +
> 1 file changed, 1 insertion(+)
>
Applied to https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git,
spi-nor/next branch.
Thanks,
ta
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-08-28 10:21 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-08-15 6:03 [PATCH] mtd: spi-nor: hisi-sfc: Add of_node_put() before break Nishka Dasgupta
2019-08-28 10:21 ` Tudor.Ambarus
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).