Skip to content

Commit 8fcc3f7

Browse files
jacmetvinodkoul
authored andcommitted
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 <[email protected]> Reviewed-by: Radhey Shyam Pandey <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Vinod Koul <[email protected]>
1 parent 33b7db4 commit 8fcc3f7

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

drivers/dma/xilinx/xilinx_dma.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,9 @@
112112

113113
/* Register Direct Mode Registers */
114114
#define XILINX_DMA_REG_VSIZE 0x0000
115+
#define XILINX_DMA_VSIZE_MASK GENMASK(12, 0)
115116
#define XILINX_DMA_REG_HSIZE 0x0004
117+
#define XILINX_DMA_HSIZE_MASK GENMASK(15, 0)
116118

117119
#define XILINX_DMA_REG_FRMDLY_STRIDE 0x0008
118120
#define XILINX_DMA_FRMDLY_STRIDE_FRMDLY_SHIFT 24
@@ -2050,6 +2052,10 @@ xilinx_vdma_dma_prep_interleaved(struct dma_chan *dchan,
20502052
if (!xt->numf || !xt->sgl[0].size)
20512053
return NULL;
20522054

2055+
if (xt->numf & ~XILINX_DMA_VSIZE_MASK ||
2056+
xt->sgl[0].size & ~XILINX_DMA_HSIZE_MASK)
2057+
return NULL;
2058+
20532059
if (xt->frame_size != 1)
20542060
return NULL;
20552061

0 commit comments

Comments
 (0)