diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2011-01-12 07:02:28 -0500 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2011-01-31 06:33:08 -0500 |
commit | 1fa81c270da4d8dffa84fcca448654a10ed0a5dc (patch) | |
tree | 2582ad91ea12c462745b2ef11d0fccfee73acee5 /drivers/dma/imx-sdma.c | |
parent | b9b3f82f94b52ebb0bbdf6cd77ccc5e8ee3f53b5 (diff) |
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/imx-sdma.c')
-rw-r--r-- | drivers/dma/imx-sdma.c | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/drivers/dma/imx-sdma.c b/drivers/dma/imx-sdma.c index c50305043f15..8707723e36da 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( | |||
925 | ret = -EINVAL; | 925 | ret = -EINVAL; |
926 | goto err_out; | 926 | goto err_out; |
927 | } | 927 | } |
928 | if (sdmac->word_size == DMA_SLAVE_BUSWIDTH_4_BYTES) | 928 | |
929 | switch (sdmac->word_size) { | ||
930 | case DMA_SLAVE_BUSWIDTH_4_BYTES: | ||
929 | bd->mode.command = 0; | 931 | bd->mode.command = 0; |
930 | else | 932 | if (count & 3 || sg->dma_address & 3) |
931 | bd->mode.command = sdmac->word_size; | 933 | return NULL; |
934 | break; | ||
935 | case DMA_SLAVE_BUSWIDTH_2_BYTES: | ||
936 | bd->mode.command = 2; | ||
937 | if (count & 1 || sg->dma_address & 1) | ||
938 | return NULL; | ||
939 | break; | ||
940 | case DMA_SLAVE_BUSWIDTH_1_BYTE: | ||
941 | bd->mode.command = 1; | ||
942 | break; | ||
943 | default: | ||
944 | return NULL; | ||
945 | } | ||
932 | 946 | ||
933 | param = BD_DONE | BD_EXTD | BD_CONT; | 947 | param = BD_DONE | BD_EXTD | BD_CONT; |
934 | 948 | ||