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

Commit 693d06df authored by Abhishek Sahu's avatar Abhishek Sahu Committed by Greg Kroah-Hartman
Browse files

mtd: rawnand: fix return value check for bad block status



commit e9893e6fa932f42c90c4ac5849fa9aa0f0f00a34 upstream.

Positive return value from read_oob() is making false BAD
blocks. For some of the NAND controllers, OOB bytes will be
protected with ECC and read_oob() will return number of bitflips.
If there is any bitflip in ECC protected OOB bytes for BAD block
status page, then that block is getting treated as BAD.

Fixes: c120e75e ("mtd: nand: use read_oob() instead of cmdfunc() for bad block check")
Cc: <stable@vger.kernel.org>
Signed-off-by: default avatarAbhishek Sahu <absahu@codeaurora.org>
Reviewed-by: default avatarMiquel Raynal <miquel.raynal@bootlin.com>
Signed-off-by: default avatarBoris Brezillon <boris.brezillon@bootlin.com>
[backported to 4.14.y]
Signed-off-by: default avatarAbhishek Sahu <absahu@codeaurora.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 0ed70f20
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -440,7 +440,7 @@ static int nand_block_bad(struct mtd_info *mtd, loff_t ofs)

	for (; page < page_end; page++) {
		res = chip->ecc.read_oob(mtd, chip, page);
		if (res)
		if (res < 0)
			return res;

		bad = chip->oob_poi[chip->badblockpos];