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 --- drivers/mtd/nand/raw/nand_onfi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/mtd/nand/raw/nand_onfi.c b/drivers/mtd/nand/raw/nand_onfi.c index 0b879bd0a68c..8fe8d7bdd203 100644 --- a/drivers/mtd/nand/raw/nand_onfi.c +++ b/drivers/mtd/nand/raw/nand_onfi.c @@ -173,7 +173,7 @@ int nand_onfi_detect(struct nand_chip *chip) }
if (onfi_crc16(ONFI_CRC_BASE, (u8 *)&p[i], 254) == - le16_to_cpu(p->crc)) { + le16_to_cpu(p[i].crc)) { if (i) memcpy(p, &p[i], sizeof(*p)); break;
Hi
[This is an automated email]
This commit has been processed because it contains a "Fixes:" tag fixing commit: 39138c1f4a31 ("mtd: rawnand: use bit-wise majority to recover the ONFI param page").
The bot has tested the following trees: v5.6.7, v5.4.35, v4.19.118.
v5.6.7: Build OK! v5.4.35: Build OK! v4.19.118: Failed to apply! Possible dependencies: 0f808c1602bc ("mtd: rawnand: Pass a nand_chip object to chip->cmd_ctrl()") 1c325cc5077a ("mtd: rawnand: Move ONFI code to nand_onfi.c") 348d56a8c606 ("mtd: rawnand: Keep all internal stuff private") 3d4af7c19585 ("mtd: rawnand: Move legacy code to nand_legacy.c") 45240367939b ("mtd: rawnand: Deprecate ->{set,get}_features() hooks") 47bd59e538d4 ("mtd: rawnand: plat_nand: Pass a nand_chip object to all platform_nand_ctrl hooks") 716bbbabcc68 ("mtd: rawnand: Deprecate ->{read, write}_{byte, buf}() hooks") 7e534323c416 ("mtd: rawnand: Pass a nand_chip object to chip->read_xxx() hooks") 82fc5099744e ("mtd: rawnand: Create a legacy struct and move ->IO_ADDR_{R, W} there") c0739d85723a ("mtd: rawnand: Pass a nand_chip object to chip->write_xxx() hooks")
NOTE: The patch will not be queued to stable trees until it is upstream.
How should we proceed with this patch?
On Tue, 2020-04-28 at 09:42:56 UTC, Miquel Raynal wrote:
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
Applied to https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git nand/next.
Miquel
linux-stable-mirror@lists.linaro.org