summaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorAhmad Fatoum <a.fatoum@pengutronix.de>2020-10-07 11:50:54 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2020-10-09 08:48:02 +0200
commit4229b5848b76ec53c523f4c0a2ad19afd07b16de (patch)
tree4c8c1dabaf7d5352eddad704952c50f24ce0d05a /drivers
parent000c93c0e2478551896d4e09987b7a69eb258fcb (diff)
downloadbarebox-4229b5848b76ec53c523f4c0a2ad19afd07b16de.tar.gz
barebox-4229b5848b76ec53c523f4c0a2ad19afd07b16de.tar.xz
dma: apbh: fix out-of-bounds write on 64-bit SoCs
i.MX8 MM & MN are both ARM64 SoCs with a device compatible with "fsl,imx28-dma-apbh". Probing the barebox device driver on these SoCs would invoke undefined behavior however, because of an errant cast. Fix this. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/dma/apbh_dma.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/drivers/dma/apbh_dma.c b/drivers/dma/apbh_dma.c
index 3bee89f78b..0e4961f6cb 100644
--- a/drivers/dma/apbh_dma.c
+++ b/drivers/dma/apbh_dma.c
@@ -50,6 +50,7 @@
static struct mxs_dma_chan mxs_dma_channels[MXS_MAX_DMA_CHANNELS];
enum mxs_dma_id {
+ UNKNOWN_DMA_ID,
IMX23_DMA,
IMX28_DMA,
};
@@ -596,9 +597,9 @@ static int apbh_dma_probe(struct device_d *dev)
enum mxs_dma_id id;
int ret, channel;
- ret = dev_get_drvdata(dev, (const void **)&id);
- if (ret)
- return ret;
+ id = (enum mxs_dma_id)device_get_match_data(dev);
+ if (id == UNKNOWN_DMA_ID)
+ return -ENODEV;
apbh_dma = apbh = xzalloc(sizeof(*apbh));
iores = dev_request_mem_resource(dev, 0);