Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7912a5e7 authored by Stanislav Fomichev's avatar Stanislav Fomichev Committed by David Woodhouse
Browse files

mtd: nand: fix pointer NULL pointer dereferencing



In 'verify_bbt_descr()', first check the "bd" pointer, then
dereference it.

Comments amended by Artem.

Signed-off-by: default avatarStanislav Fomichev <kernel@fomichev.me>
Signed-off-by: default avatarArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
Signed-off-by: default avatarDavid Woodhouse <David.Woodhouse@intel.com>
parent 7b7e905e
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -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);