dmaengine i.MX dma: check sg entries for valid addresses and lengths
authorSascha Hauer <s.hauer@pengutronix.de>
Wed, 12 Jan 2011 13:13:23 +0000 (14:13 +0100)
committerSascha Hauer <s.hauer@pengutronix.de>
Mon, 31 Jan 2011 11:36:02 +0000 (12:36 +0100)
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
drivers/dma/imx-dma.c

index a46e1d9fa3e43bb198a949e31885fce9f8bed120..a1eac99a5fa1fd2991584605708c9a26295d6fc4 100644 (file)
@@ -243,6 +243,21 @@ static struct dma_async_tx_descriptor *imxdma_prep_slave_sg(
        else
                dmamode = DMA_MODE_WRITE;
 
+       switch (imxdmac->word_size) {
+       case DMA_SLAVE_BUSWIDTH_4_BYTES:
+               if (sgl->length & 3 || sgl->dma_address & 3)
+                       return NULL;
+               break;
+       case DMA_SLAVE_BUSWIDTH_2_BYTES:
+               if (sgl->length & 1 || sgl->dma_address & 1)
+                       return NULL;
+               break;
+       case DMA_SLAVE_BUSWIDTH_1_BYTE:
+               break;
+       default:
+               return NULL;
+       }
+
        ret = imx_dma_setup_sg(imxdmac->imxdma_channel, sgl, sg_len,
                 dma_length, imxdmac->per_address, dmamode);
        if (ret)