[PATCH] dmaengine: rcar-dmac: Make rcar_dmac_of_xlate() more robust

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Add an upper bound check for the MID/RID value passed from DT via the
DMA spec.

This avoids writing to reserved bits in the DMARS registers in case of
an out-of-range value in DT.

Suggested-by: Renesas BSP team via Yoshihiro Shimoda <yoshihiro.shimoda.uh@xxxxxxxxxxx>
Signed-off-by: Geert Uytterhoeven <geert+renesas@xxxxxxxxx>
---
 drivers/dma/sh/rcar-dmac.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/dma/sh/rcar-dmac.c b/drivers/dma/sh/rcar-dmac.c
index 72572320208dbb9a..73cf1053bed90244 100644
--- a/drivers/dma/sh/rcar-dmac.c
+++ b/drivers/dma/sh/rcar-dmac.c
@@ -1644,8 +1644,11 @@ static struct dma_chan *rcar_dmac_of_xlate(struct of_phandle_args *dma_spec,
 	struct dma_chan *chan;
 	dma_cap_mask_t mask;
 
-	if (dma_spec->args_count != 1)
+	if (dma_spec->args_count != 1 || dma_spec->args[0] > 0xff) {
+		pr_info("%s: invalid MID/RID 0x%x... for %pOF\n", __func__,
+			dma_spec->args[0], dma_spec->np);
 		return NULL;
+	}
 
 	/* Only slave DMA channels can be allocated via DT */
 	dma_cap_zero(mask);
-- 
2.17.1

--
To unsubscribe from this list: send the line "unsubscribe dmaengine" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Kernel]     [Linux ARM (vger)]     [Linux ARM MSM]     [Linux Omap]     [Linux Arm]     [Linux Tegra]     [Fedora ARM]     [Linux for Samsung SOC]     [eCos]     [Linux PCI]     [Linux Fastboot]     [Gcc Help]     [Git]     [DCCP]     [IETF Announce]     [Security]     [Linux MIPS]     [Yosemite Campsites]

  Powered by Linux