mtd: nand_bbt: handle error case for nand_create_badblock_pattern()
authorBrian Norris <computersforpeace@gmail.com>
Wed, 21 May 2014 05:34:40 +0000 (22:34 -0700)
committerBrian Norris <computersforpeace@gmail.com>
Wed, 28 May 2014 07:05:25 +0000 (00:05 -0700)
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
drivers/mtd/nand/nand_bbt.c

index 6cbf8768a0a40b577e17dcab20272f65f21769db..7f0c3b4c2a4fdc045f42ca8b5bc54f97815b3484 100644 (file)
@@ -1282,6 +1282,7 @@ static int nand_create_badblock_pattern(struct nand_chip *this)
 int nand_default_bbt(struct mtd_info *mtd)
 {
        struct nand_chip *this = mtd->priv;
+       int ret;
 
        /* Is a flash based bad block table requested? */
        if (this->bbt_options & NAND_BBT_USE_FLASH) {
@@ -1300,8 +1301,11 @@ int nand_default_bbt(struct mtd_info *mtd)
                this->bbt_md = NULL;
        }
 
-       if (!this->badblock_pattern)
-               nand_create_badblock_pattern(this);
+       if (!this->badblock_pattern) {
+               ret = nand_create_badblock_pattern(this);
+               if (ret)
+                       return ret;
+       }
 
        return nand_scan_bbt(mtd, this->badblock_pattern);
 }