Blob Blame History Raw
From 868cbe2a6dcee451bd8f87cbbb2a73cf463b57e5 Mon Sep 17 00:00:00 2001
From: Miquel Raynal <miquel.raynal@bootlin.com>
Date: Thu, 1 Oct 2020 12:20:13 +0200
Subject: [PATCH] mtd: spinand: Fix OOB read
Git-commit: 868cbe2a6dcee451bd8f87cbbb2a73cf463b57e5
Patch-mainline: v5.11-rc1
References: git-fixes

So far OOB have never been used in SPI-NAND, add the missing memcpy to
make it work properly.

Fixes: 7529df465248 ("mtd: nand: Add core infrastructure to support SPI NANDs")
Cc: stable@vger.kernel.org
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20201001102014.20100-6-miquel.raynal@bootlin.com
Acked-by: Takashi Iwai <tiwai@suse.de>

---
 drivers/mtd/nand/spi/core.c |    4 ++++
 1 file changed, 4 insertions(+)

--- a/drivers/mtd/nand/spi/core.c
+++ b/drivers/mtd/nand/spi/core.c
@@ -317,6 +317,10 @@ static int spinand_write_to_cache_op(str
 		buf += ret;
 	}
 
+	if (req->ooblen)
+		memcpy(req->oobbuf.in, spinand->oobbuf + req->ooboffs,
+		       req->ooblen);
+
 	return 0;
 }