[U-Boot] [PATCH 3/3] spi: fsl_quadspi: Fix qspi_op_rdid memcpy issue

Gong Q.Y. Qianyu.Gong at freescale.com
Mon Dec 14 11:46:47 CET 2015


Oh, so sorry for the mess... The network seems to get problems..:(

Regards,
Qianyu

> -----Original Message-----
> From: Gong Qianyu [mailto:Qianyu.Gong at freescale.com]
> Sent: Monday, December 14, 2015 6:37 PM
> To: u-boot at lists.denx.de
> Cc: Hu Mingkai-B21284; Sun York-R58495; Yuan Yao-B46683;
> jteki at openedev.com; Gong Qianyu-B52263
> Subject: [PATCH 3/3] spi: fsl_quadspi: Fix qspi_op_rdid memcpy issue
> 
> In current driver everytime we memcpy 4 bytes to the dest memory
> regardless of the remaining length.
> This patch add checking the remaining length before memcpy.
> If the length is shorter than 4 bytes, memcpy the actual length of data
> to the dest memory.
> 
> Signed-off-by: Gong Qianyu <Qianyu.Gong at freescale.com>
> ---
>  drivers/spi/fsl_qspi.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/spi/fsl_qspi.c b/drivers/spi/fsl_qspi.c index
> 755cc27..b41b226 100644
> --- a/drivers/spi/fsl_qspi.c
> +++ b/drivers/spi/fsl_qspi.c
> @@ -499,7 +499,10 @@ static void qspi_op_rdid(struct fsl_qspi_priv *priv,
> u32 *rxbuf, u32 len)
>  		if (rbsr_reg & QSPI_RBSR_RDBFL_MASK) {
>  			data = qspi_read32(priv->flags, &regs->rbdr[i]);
>  			data = qspi_endian_xchg(data);
> -			memcpy(rxbuf, &data, 4);
> +			if (size < 4)
> +				memcpy(rxbuf, &data, size);
> +			else
> +				memcpy(rxbuf, &data, 4);
>  			rxbuf++;
>  			size -= 4;
>  			i++;
> --
> 2.1.0.27.g96db324



More information about the U-Boot mailing list