lkml.org 
[lkml]   [2019]   [Oct]   [4]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH v2] mtd: onenand: prevent memory leak in onenand_scan
Date
In onenand_scan if scan_bbt fails the allocated buffers for oob_buf,
verify_buf, and page_buf should be released.

Fixes: 5988af231978 ("mtd: Flex-OneNAND support")
Signed-off-by: Navid Emamdoost <navid.emamdoost@gmail.com>
---
Changes in v2:
-- added release for this->verify_buf (thanks to Miquel Raynal
for the hint).
---
drivers/mtd/nand/onenand/onenand_base.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/mtd/nand/onenand/onenand_base.c b/drivers/mtd/nand/onenand/onenand_base.c
index 77bd32a683e1..6329ada3f15c 100644
--- a/drivers/mtd/nand/onenand/onenand_base.c
+++ b/drivers/mtd/nand/onenand/onenand_base.c
@@ -3977,8 +3977,14 @@ int onenand_scan(struct mtd_info *mtd, int maxchips)
this->badblockpos = ONENAND_BADBLOCK_POS;

ret = this->scan_bbt(mtd);
- if ((!FLEXONENAND(this)) || ret)
+ if ((!FLEXONENAND(this)) || ret) {
+ kfree(this->oob_buf);
+#ifdef CONFIG_MTD_ONENAND_VERIFY_WRITE
+ kfree(this->verify_buf);
+#endif
+ kfree(this->page_buf);
return ret;
+ }

/* Change Flex-OneNAND boundaries if required */
for (i = 0; i < MAX_DIES; i++)
--
2.17.1
\
 
 \ /
  Last update: 2019-10-04 19:19    [W:0.085 / U:1.152 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site