Linux-mtd Archive on lore.kernel.org
 help / color / Atom feed
* [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	[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, back to index

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

Linux-mtd Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-mtd/0 linux-mtd/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-mtd linux-mtd/ https://lore.kernel.org/linux-mtd \
		linux-mtd@lists.infradead.org linux-mtd@archiver.kernel.org
	public-inbox-index linux-mtd


Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.infradead.lists.linux-mtd


AGPL code for this site: git clone https://public-inbox.org/ public-inbox