mtd: rawnand: onfi: Fix redundancy detection check
commit02f8e8c0d7535d81fad58914ff49498f39ba52a6
authorMiquel Raynal <miquel.raynal@bootlin.com>
Tue, 28 Apr 2020 09:42:56 +0000 (28 11:42 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 22 Jun 2020 07:33:09 +0000 (22 09:33 +0200)
treed54430e335233391faf746157f84c489e40fe6c8
parent6a2eb002e4bd84a8fff06709152f694633c2fe80
mtd: rawnand: onfi: Fix redundancy detection check

commit 1d5d08ee9b28cff907326b4ad5a2463fd2808be1 upstream.

During ONFI detection, the CRC derived from the parameter page and the
CRC supposed to be at the end of the parameter page are compared. If
they do not match, the second then the third copies of the page are
tried.

The current implementation compares the newly derived CRC with the CRC
contained in the first page only. So if this particular CRC area has
been corrupted, then the detection will fail for a wrong reason.

Fix this issue by checking the derived CRC against the right one.

Fixes: 39138c1f4a31 ("mtd: rawnand: use bit-wise majority to recover the ONFI param page")
Cc: stable@vger.kernel.org
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Link: https://lore.kernel.org/linux-mtd/20200428094302.14624-4-miquel.raynal@bootlin.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/mtd/nand/raw/nand_onfi.c