aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/dma
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2011-01-12 13:02:28 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2011-01-31 12:33:08 +0100
commit1fa81c270da4d8dffa84fcca448654a10ed0a5dc (patch)
tree2582ad91ea12c462745b2ef11d0fccfee73acee5 /drivers/dma
parentb9b3f82f94b52ebb0bbdf6cd77ccc5e8ee3f53b5 (diff)
downloadkernel_samsung_smdk4412-1fa81c270da4d8dffa84fcca448654a10ed0a5dc.zip
kernel_samsung_smdk4412-1fa81c270da4d8dffa84fcca448654a10ed0a5dc.tar.gz
kernel_samsung_smdk4412-1fa81c270da4d8dffa84fcca448654a10ed0a5dc.tar.bz2
dmaengine i.MX sdma: check sg entries for valid addresses and lengths
This patch lets sdma_prep_slave_sg fail if the entries of an sg list do not start on multiples of the word size or if the lengths are not multiple of the word size. Also, catch the previously unhandled DMA_SLAVE_BUSWIDTH_8_BYTES and DMA_SLAVE_BUSWIDTH_UNDEFINED cases. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'drivers/dma')
-rw-r--r--drivers/dma/imx-sdma.c20
1 files changed, 17 insertions, 3 deletions
diff --git a/drivers/dma/imx-sdma.c b/drivers/dma/imx-sdma.c
index c503050..8707723 100644
--- a/drivers/dma/imx-sdma.c
+++ b/drivers/dma/imx-sdma.c
@@ -925,10 +925,24 @@ static struct dma_async_tx_descriptor *sdma_prep_slave_sg(
ret = -EINVAL;
goto err_out;
}
- if (sdmac->word_size == DMA_SLAVE_BUSWIDTH_4_BYTES)
+
+ switch (sdmac->word_size) {
+ case DMA_SLAVE_BUSWIDTH_4_BYTES:
bd->mode.command = 0;
- else
- bd->mode.command = sdmac->word_size;
+ if (count & 3 || sg->dma_address & 3)
+ return NULL;
+ break;
+ case DMA_SLAVE_BUSWIDTH_2_BYTES:
+ bd->mode.command = 2;
+ if (count & 1 || sg->dma_address & 1)
+ return NULL;
+ break;
+ case DMA_SLAVE_BUSWIDTH_1_BYTE:
+ bd->mode.command = 1;
+ break;
+ default:
+ return NULL;
+ }
param = BD_DONE | BD_EXTD | BD_CONT;