Commit 4f2c8eaf authored by Federico Vaga's avatar Federico Vaga

sw:drv:dma: validate dma_slave_config

Signed-off-by: Federico Vaga's avatarFederico Vaga <federico.vaga@cern.ch>
parent dd33c15e
...@@ -352,6 +352,7 @@ static int gn412x_dma_alloc_chan_resources(struct dma_chan *dchan) ...@@ -352,6 +352,7 @@ static int gn412x_dma_alloc_chan_resources(struct dma_chan *dchan)
struct gn412x_dma_chan *chan = to_gn412x_dma_chan(dchan); struct gn412x_dma_chan *chan = to_gn412x_dma_chan(dchan);
memset(&chan->sconfig, 0, sizeof(struct dma_slave_config)); memset(&chan->sconfig, 0, sizeof(struct dma_slave_config));
chan->sconfig.direction = DMA_DEV_TO_MEM;
return 0; return 0;
} }
...@@ -427,6 +428,12 @@ static struct dma_async_tx_descriptor *gn412x_dma_prep_slave_sg( ...@@ -427,6 +428,12 @@ static struct dma_async_tx_descriptor *gn412x_dma_prep_slave_sg(
goto err; goto err;
} }
if (unlikely(sconfig->direction != direction)) {
dev_err(&chan->dev->device,
"Transfer and slave configuration disagree on DMA direction\n");
goto err;
}
if (unlikely(!sgl || !sg_len)) { if (unlikely(!sgl || !sg_len)) {
dev_err(&chan->dev->device, dev_err(&chan->dev->device,
"You must provide a DMA scatterlist\n"); "You must provide a DMA scatterlist\n");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment