summaryrefslogtreecommitdiff
path: root/drivers/mtd
diff options
context:
space:
mode:
authorSuresh Gupta <suresh.gupta@nxp.com>2017-09-18 04:33:08 (GMT)
committerXie Xiaobo <xiaobo.xie@nxp.com>2017-09-25 07:25:53 (GMT)
commitaa0365c5b6706aa349e4a654f19b72aea8fcbdbd (patch)
treea734d170d6d034b2f3456efacab7acf318f82283 /drivers/mtd
parent219312a05027c1972b9df874e2ef3b266cee93c5 (diff)
downloadlinux-aa0365c5b6706aa349e4a654f19b72aea8fcbdbd.tar.xz
mtd: spi-nor: fsl-qspi: Limit read to specified count provided by above layer
TBDR is 4 bytes aligned buffer and to fill that, reading always 4 bytes from above layer, might exceed the boundary of above layer buffer and generate crash. patch resolve the crash of type "Unable to handle kernel paging request at virtual address **" Signed-off-by: Rajat Srivastava <rajat.srivastava@nxp.com>
Diffstat (limited to 'drivers/mtd')
-rw-r--r--drivers/mtd/spi-nor/fsl-quadspi.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/drivers/mtd/spi-nor/fsl-quadspi.c b/drivers/mtd/spi-nor/fsl-quadspi.c
index 4cdb8c6..8fb7553 100644
--- a/drivers/mtd/spi-nor/fsl-quadspi.c
+++ b/drivers/mtd/spi-nor/fsl-quadspi.c
@@ -767,6 +767,7 @@ static ssize_t fsl_qspi_nor_write(struct fsl_qspi *q, struct spi_nor *nor,
{
int ret, i, j;
u32 tmp;
+ u8 byts;
dev_dbg(q->dev, "to 0x%.8x:0x%.8x, len : %d\n",
q->chip_base_addr, to, count);
@@ -776,11 +777,13 @@ static ssize_t fsl_qspi_nor_write(struct fsl_qspi *q, struct spi_nor *nor,
qspi_writel(q, tmp | QUADSPI_MCR_CLR_TXF_MASK, q->iobase + QUADSPI_MCR);
/* fill the TX data to the FIFO */
+ byts = count;
for (j = 0, i = ((count + 3) / 4); j < i; j++) {
- u8tou32(&tmp, txbuf, 4);
+ u8tou32(&tmp, txbuf, byts);
tmp = fsl_qspi_endian_xchg(q, tmp);
qspi_writel(q, tmp, q->iobase + QUADSPI_TBDR);
txbuf += 4;
+ byts -= 4;
}
/* fill the TXFIFO upto 16 bytes for i.MX7d */