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

dmaengine: xilinx_dma: check for invalid vdma interleaved parameters

The VDMA HSIZE register (corresponding to sgl[0].size) is only 16bit wide /
the VSIZE register (corresponding to numf) is only 13bit wide, so reject
requests not fitting within that rather than silently transferring too
little data.

Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
Reviewed-by: Radhey Shyam Pandey <radhey.shyam.pandey@amd.com>
Link: https://lore.kernel.org/r/20240105105956.1370220-1-peter@korsgaard.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>

authored by

Peter Korsgaard and committed by
Vinod Koul
8fcc3f7d 33b7db45

+6
+6
drivers/dma/xilinx/xilinx_dma.c
··· 112 112 113 113 /* Register Direct Mode Registers */ 114 114 #define XILINX_DMA_REG_VSIZE 0x0000 115 + #define XILINX_DMA_VSIZE_MASK GENMASK(12, 0) 115 116 #define XILINX_DMA_REG_HSIZE 0x0004 117 + #define XILINX_DMA_HSIZE_MASK GENMASK(15, 0) 116 118 117 119 #define XILINX_DMA_REG_FRMDLY_STRIDE 0x0008 118 120 #define XILINX_DMA_FRMDLY_STRIDE_FRMDLY_SHIFT 24 ··· 2050 2048 return NULL; 2051 2049 2052 2050 if (!xt->numf || !xt->sgl[0].size) 2051 + return NULL; 2052 + 2053 + if (xt->numf & ~XILINX_DMA_VSIZE_MASK || 2054 + xt->sgl[0].size & ~XILINX_DMA_HSIZE_MASK) 2053 2055 return NULL; 2054 2056 2055 2057 if (xt->frame_size != 1)