From: Boris Brezillon Date: Fri, 1 May 2020 14:39:13 +0000 (+0200) Subject: mtd: rawnand: diskonchip: Make sure doc2001plus_readbuf() works for single byte reads X-Git-Tag: rel_imx_5.10.35_2.0.0-somdevices.0~1957^2~5^2~124 X-Git-Url: https://git.somdevices.com/?a=commitdiff_plain;h=a50b0c20bedcf10599708bed1608209274899053;p=linux.git mtd: rawnand: diskonchip: Make sure doc2001plus_readbuf() works for single byte reads Single byte accesses normally go through read_byte() but we are about to use this function in the exec_op() implementation and thus needs to prepare for single byte reads. Signed-off-by: Boris Brezillon Signed-off-by: Miquel Raynal Link: https://lore.kernel.org/linux-mtd/20200501143917.1388957-2-boris.brezillon@collabora.com --- diff --git a/drivers/mtd/nand/raw/diskonchip.c b/drivers/mtd/nand/raw/diskonchip.c index 4c3d04da4cee..ab5a36671e72 100644 --- a/drivers/mtd/nand/raw/diskonchip.c +++ b/drivers/mtd/nand/raw/diskonchip.c @@ -550,9 +550,12 @@ static void doc2001plus_readbuf(struct nand_chip *this, u_char *buf, int len) } /* Terminate read pipeline */ - buf[len - 2] = ReadDOC(docptr, Mplus_LastDataRead); - if (debug && i < 16) - printk("%02x ", buf[len - 2]); + if (len >= 2) { + buf[len - 2] = ReadDOC(docptr, Mplus_LastDataRead); + if (debug && i < 16) + printk("%02x ", buf[len - 2]); + } + buf[len - 1] = ReadDOC(docptr, Mplus_LastDataRead); if (debug && i < 16) printk("%02x ", buf[len - 1]);