mtd: nand: don't leak buffers when ->scan_bbt() fails

Linux-MTD Mailing List linux-mtd at lists.infradead.org
Thu Jun 1 11:59:01 PDT 2017


Gitweb:     http://git.infradead.org/?p=mtd-2.6.git;a=commit;h=44d4182e23c555cbfa8b8a0ad2d94664d23850d3
Commit:     44d4182e23c555cbfa8b8a0ad2d94664d23850d3
Parent:     08332893e37af6ae779367e78e444f8f9571511d
Author:     Brian Norris <computersforpeace at gmail.com>
AuthorDate: Mon May 1 17:04:50 2017 -0700
Committer:  Boris Brezillon <boris.brezillon at free-electrons.com>
CommitDate: Mon May 22 09:42:29 2017 +0200

    mtd: nand: don't leak buffers when ->scan_bbt() fails
    
    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")
    
    Signed-off-by: Brian Norris <computersforpeace at gmail.com>
    Acked-by: Ezequiel Garcia <ezequiel at vanguardiasur.com.ar>
    Signed-off-by: Boris Brezillon <boris.brezillon at free-electrons.com>
---
 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 d474378..6678229 100644
--- a/drivers/mtd/nand/nand_base.c
+++ b/drivers/mtd/nand/nand_base.c
@@ -4842,7 +4842,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);



More information about the linux-mtd-cvs mailing list