diff mbox series

dmaengine: imx-sdma: initialize all script addresses

Message ID 20200513060405.18685-1-s.hauer@pengutronix.de (mailing list archive)
State Mainlined
Commit be4cf718cd9929e867ed1ff06d23fb4d08cc2d36
Headers show
Series dmaengine: imx-sdma: initialize all script addresses | expand

Commit Message

Sascha Hauer May 13, 2020, 6:04 a.m. UTC
The script addresses array increases with each new version. The driver
initializes the array to -EINVAL initially, but only up to the size
of the v1 array. Initialize the additional addresses for the newer
versions as well. Without this unitialized values of the newer arrays
are treated as valid.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 drivers/dma/imx-sdma.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Robin Gong May 13, 2020, 8:02 a.m. UTC | #1
On 2020/05/13 14:04 Sascha Hauer <s.hauer@pengutronix.de> wrote:
> The script addresses array increases with each new version. The driver
> initializes the array to -EINVAL initially, but only up to the size of the v1 array.
> Initialize the additional addresses for the newer versions as well. Without this
> unitialized values of the newer arrays are treated as valid.
> 
> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
> ---
>  drivers/dma/imx-sdma.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/dma/imx-sdma.c b/drivers/dma/imx-sdma.c index
> 01422e721b26e..2ca79357f57dc 100644
> --- a/drivers/dma/imx-sdma.c
> +++ b/drivers/dma/imx-sdma.c
> @@ -2080,7 +2080,7 @@ static int sdma_probe(struct platform_device *pdev)
> 
>  	/* initially no scripts available */
>  	saddr_arr = (s32 *)sdma->script_addrs;
> -	for (i = 0; i < SDMA_SCRIPT_ADDRS_ARRAY_SIZE_V1; i++)
> +	for (i = 0; i < sizeof(*sdma->script_addrs) / sizeof(s32); i++)
>  		saddr_arr[i] = -EINVAL;
Reviewed-by : Robin Gong <yibin.gong@nxp.com>
> 
>  	dma_cap_set(DMA_SLAVE, sdma->dma_device.cap_mask);
> --
> 2.26.2
Vinod Koul May 15, 2020, 6:57 a.m. UTC | #2
On 13-05-20, 08:04, Sascha Hauer wrote:
> The script addresses array increases with each new version. The driver
> initializes the array to -EINVAL initially, but only up to the size
> of the v1 array. Initialize the additional addresses for the newer
> versions as well. Without this unitialized values of the newer arrays
> are treated as valid.

Applied, thanks
diff mbox series

Patch

diff --git a/drivers/dma/imx-sdma.c b/drivers/dma/imx-sdma.c
index 01422e721b26e..2ca79357f57dc 100644
--- a/drivers/dma/imx-sdma.c
+++ b/drivers/dma/imx-sdma.c
@@ -2080,7 +2080,7 @@  static int sdma_probe(struct platform_device *pdev)
 
 	/* initially no scripts available */
 	saddr_arr = (s32 *)sdma->script_addrs;
-	for (i = 0; i < SDMA_SCRIPT_ADDRS_ARRAY_SIZE_V1; i++)
+	for (i = 0; i < sizeof(*sdma->script_addrs) / sizeof(s32); i++)
 		saddr_arr[i] = -EINVAL;
 
 	dma_cap_set(DMA_SLAVE, sdma->dma_device.cap_mask);