remoteproc: imx_rproc: fix a couple off by one bugs
authorDan Carpenter <dan.carpenter@oracle.com>
Thu, 5 Oct 2017 12:58:27 +0000 (15:58 +0300)
committerBjorn Andersson <bjorn.andersson@linaro.org>
Tue, 10 Oct 2017 18:22:55 +0000 (11:22 -0700)
The priv->mem[] array has IMX7D_RPROC_MEM_MAX elements so the > should
be >= to avoid writing one element beyond the end of the array.

Fixes: a0ff4aa6f010 ("remoteproc: imx_rproc: add a NXP/Freescale imx_rproc driver")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
drivers/remoteproc/imx_rproc.c

index 612d914033414e3b17dea2b8bac97584cb280f1c..81ba44510b7545ba888242322a816d4af2cfbb73 100644 (file)
@@ -264,7 +264,7 @@ static int imx_rproc_addr_init(struct imx_rproc *priv,
                if (!(att->flags & ATT_OWN))
                        continue;
 
-               if (b > IMX7D_RPROC_MEM_MAX)
+               if (b >= IMX7D_RPROC_MEM_MAX)
                        break;
 
                priv->mem[b].cpu_addr = devm_ioremap(&pdev->dev,
@@ -296,7 +296,7 @@ static int imx_rproc_addr_init(struct imx_rproc *priv,
                        return err;
                }
 
-               if (b > IMX7D_RPROC_MEM_MAX)
+               if (b >= IMX7D_RPROC_MEM_MAX)
                        break;
 
                priv->mem[b].cpu_addr = devm_ioremap_resource(&pdev->dev, &res);