mtd: nand: fix pointer NULL pointer dereferencing
authorStanislav Fomichev <kernel@fomichev.me>
Mon, 7 Feb 2011 20:48:25 +0000 (23:48 +0300)
committerDavid Woodhouse <David.Woodhouse@intel.com>
Fri, 11 Mar 2011 14:22:44 +0000 (14:22 +0000)
In 'verify_bbt_descr()', first check the "bd" pointer, then
dereference it.

Comments amended by Artem.

Signed-off-by: Stanislav Fomichev <kernel@fomichev.me>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
drivers/mtd/nand/nand_bbt.c

index 6ebd869993aa9c976dadd1c4bb44160e9ec24843..a1e8b30078d9a6a0d6c2289f495d5b158d66aad0 100644 (file)
@@ -1101,12 +1101,16 @@ static void mark_bbt_region(struct mtd_info *mtd, struct nand_bbt_descr *td)
 static void verify_bbt_descr(struct mtd_info *mtd, struct nand_bbt_descr *bd)
 {
        struct nand_chip *this = mtd->priv;
-       u32 pattern_len = bd->len;
-       u32 bits = bd->options & NAND_BBT_NRBITS_MSK;
+       u32 pattern_len;
+       u32 bits;
        u32 table_size;
 
        if (!bd)
                return;
+
+       pattern_len = bd->len;
+       bits = bd->options & NAND_BBT_NRBITS_MSK;
+
        BUG_ON((this->options & NAND_USE_FLASH_BBT_NO_OOB) &&
                        !(this->options & NAND_USE_FLASH_BBT));
        BUG_ON(!bits);