dmaengine: xdma: Check zero length scatter list segment
Subsystems (3)
Lizhi Hou
maintainerPATCH 1/1 dmaengine: xdma: Check zero length scatter list segment
In callback function xdma_prep_device_sg(), it is nice to check if there is zero length segment and skip it in the input scatter list.
Reported-by Martin Tuma <[email protected]>
Signed-off-by Lizhi Hou <[email protected]>
--- drivers/dma/xilinx/xdma.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/dma/xilinx/xdma.c +4 -2
@@ -465,6 +465,8 @@ xdma_prep_device_sg(struct dma_chan *chan, struct scatterlist *sgl,for_each_sg (sgl, sg, sg_len, i) desc_num +=DIV_ROUND_UP (sg_dma_len (sg),XDMA_DESC_BLEN_MAX ); +if (!desc_num) +return NULL ; sw_desc =xdma_alloc_desc (xdma_chan, desc_num);if (!sw_desc)
@@ -488,7 +490,7 @@ xdma_prep_device_sg(struct dma_chan *chan, struct scatterlist *sgl, addr =sg_dma_address (sg); rest =sg_dma_len (sg); - do { +while (rest) { len =min_t (u32, rest,XDMA_DESC_BLEN_MAX );/* set hardware descriptor */ desc->bytes =cpu_to_le32 (len);
@@ -506,7 +508,7 @@ xdma_prep_device_sg(struct dma_chan *chan, struct scatterlist *sgl, dev_addr += len; addr += len; rest -= len; - }while (rest); + }; } tx_desc =vchan_tx_prep (&xdma_chan->vchan, &sw_desc->vdesc, flags);
Signature · 1 line
2.27.0