[PATCH] mtd: nand: don't leak buffers when ->scan_bbt() fails
Brian Norris
computersforpeace at gmail.com
Mon May 1 17:04:50 PDT 2017
This bug seems to have been here forever, although we came close to
fixing all of them in [1]!
[1] 11eaf6df1cce ("mtd: nand: Remove BUG() abuse in nand_scan_tail")
Cc: Ezequiel Garcia <ezequiel at vanguardiasur.com.ar>
Signed-off-by: Brian Norris <computersforpeace at gmail.com>
---
The goto isn't *really* necessary, but I thought it'd be more consistent.
Compile tested only
drivers/mtd/nand/nand_base.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
index 978242b1213f..e4919f9dece4 100644
--- a/drivers/mtd/nand/nand_base.c
+++ b/drivers/mtd/nand/nand_base.c
@@ -4794,7 +4794,11 @@ int nand_scan_tail(struct mtd_info *mtd)
return 0;
/* Build bad block table */
- return chip->scan_bbt(mtd);
+ ret = chip->scan_bbt(mtd);
+ if (ret)
+ goto err_free;
+ return 0;
+
err_free:
if (nbuf) {
kfree(nbuf->databuf);
--
2.13.0.rc1.294.g07d810a77f-goog
More information about the linux-mtd
mailing list