Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

dmaengine i.MX dma: check sg entries for valid addresses and lengths

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>

+15
+15
drivers/dma/imx-dma.c
··· 243 243 else 244 244 dmamode = DMA_MODE_WRITE; 245 245 246 + switch (imxdmac->word_size) { 247 + case DMA_SLAVE_BUSWIDTH_4_BYTES: 248 + if (sgl->length & 3 || sgl->dma_address & 3) 249 + return NULL; 250 + break; 251 + case DMA_SLAVE_BUSWIDTH_2_BYTES: 252 + if (sgl->length & 1 || sgl->dma_address & 1) 253 + return NULL; 254 + break; 255 + case DMA_SLAVE_BUSWIDTH_1_BYTE: 256 + break; 257 + default: 258 + return NULL; 259 + } 260 + 246 261 ret = imx_dma_setup_sg(imxdmac->imxdma_channel, sgl, sg_len, 247 262 dma_length, imxdmac->per_address, dmamode); 248 263 if (ret)