mtd: rawnand: fix return value check for bad block status
authorAbhishek Sahu <absahu@codeaurora.org>
Wed, 13 Jun 2018 09:02:36 +0000 (14:32 +0530)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 8 Jul 2018 13:30:51 +0000 (15:30 +0200)
commit693d06dffb436ae22c899e0ffd7c28064dd8ec32
tree42e95b01792e9d25352e94f7f6cdc68d709607ab
parent0ed70f20644959caf01a89b17fccebd19b204d92
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: c120e75e0e7d ("mtd: nand: use read_oob() instead of cmdfunc() for bad block check")
Cc: <stable@vger.kernel.org>
Signed-off-by: Abhishek Sahu <absahu@codeaurora.org>
Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>
Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
[backported to 4.14.y]
Signed-off-by: Abhishek Sahu <absahu@codeaurora.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/mtd/nand/nand_base.c