Skip to content

Commit

Permalink
mtd: nand: fix pointer NULL pointer dereferencing
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Stanislav Fomichev authored and David Woodhouse committed Mar 11, 2011
1 parent 7b7e905 commit 7912a5e
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions drivers/mtd/nand/nand_bbt.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 7912a5e

Please sign in to comment.