summaryrefslogtreecommitdiffstats
path: root/drivers/mtd/nand/onenand
diff options
context:
space:
mode:
authorWenwen Wang <wenwen@cs.uga.edu>2019-08-18 17:52:49 +0200
committerMiquel Raynal <miquel.raynal@bootlin.com>2019-08-24 13:13:39 +0200
commitd83aef09aaa50bdafbb32981859128299abf32eb (patch)
treefaa7c1781810be5a58d71842bab57fe91be72c24 /drivers/mtd/nand/onenand
parentmtd: rawnand: remove redundant assignment to variable ret (diff)
downloadlinux-d83aef09aaa50bdafbb32981859128299abf32eb.tar.xz
linux-d83aef09aaa50bdafbb32981859128299abf32eb.zip
mtd: onenand_base: Fix a memory leak bug
In onenand_scan(), if CONFIG_MTD_ONENAND_VERIFY_WRITE is defined, 'this->verify_buf' is allocated through kzalloc(). However, it is not deallocated in the following execution, if the allocation for 'this->oob_buf' fails, leading to a memory leak bug. To fix this issue, free 'this->verify_buf' before returning the error. Signed-off-by: Wenwen Wang <wenwen@cs.uga.edu> Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Diffstat (limited to 'drivers/mtd/nand/onenand')
-rw-r--r--drivers/mtd/nand/onenand/onenand_base.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/drivers/mtd/nand/onenand/onenand_base.c b/drivers/mtd/nand/onenand/onenand_base.c
index a1f8fe1abb10..dd9fced3a283 100644
--- a/drivers/mtd/nand/onenand/onenand_base.c
+++ b/drivers/mtd/nand/onenand/onenand_base.c
@@ -3879,6 +3879,9 @@ int onenand_scan(struct mtd_info *mtd, int maxchips)
if (!this->oob_buf) {
if (this->options & ONENAND_PAGEBUF_ALLOC) {
this->options &= ~ONENAND_PAGEBUF_ALLOC;
+#ifdef CONFIG_MTD_ONENAND_VERIFY_WRITE
+ kfree(this->verify_buf);
+#endif
kfree(this->page_buf);
}
return -ENOMEM;