diff options
author | Suresh Gupta <suresh.gupta@nxp.com> | 2017-09-18 04:33:08 (GMT) |
---|---|---|
committer | Xie Xiaobo <xiaobo.xie@nxp.com> | 2017-09-25 07:25:53 (GMT) |
commit | aa0365c5b6706aa349e4a654f19b72aea8fcbdbd (patch) | |
tree | a734d170d6d034b2f3456efacab7acf318f82283 /drivers/mtd | |
parent | 219312a05027c1972b9df874e2ef3b266cee93c5 (diff) | |
download | linux-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.c | 5 |
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 */ |