lkml.org 
[lkml]   [2019]   [Sep]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] mtd: onenand: prevent memory leak in onenand_scan
Date
In onenand_scan if scan_bbt fails the allocated buffers should be
released.

Signed-off-by: Navid Emamdoost <navid.emamdoost@gmail.com>
---
drivers/mtd/nand/onenand/onenand_base.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/mtd/nand/onenand/onenand_base.c b/drivers/mtd/nand/onenand/onenand_base.c
index 77bd32a683e1..79c01f42925a 100644
--- a/drivers/mtd/nand/onenand/onenand_base.c
+++ b/drivers/mtd/nand/onenand/onenand_base.c
@@ -3977,8 +3977,11 @@ 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->page_buf);
+ kfree(this->oob_buf);
return ret;
+ }

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