Re: [PATCH 1/5] dmaengine: xilinx_dma: Reject transfers that map no data
From: Frank Li
Date: Tue Oct 27 2026 - 12:44:02 EST
On Thu, Oct 22, 2026 at 03:11:30PM -0700, Jeff C. Jensen wrote:
> If every entry of a scatterlist or a DMA vector array has zero length,
> the preparation loops in xilinx_dma_prep_slave_sg(),
> xilinx_dma_prep_peripheral_dma_vec() and xilinx_mcdma_prep_slave_sg()
> allocate no segments. Each function then takes list_first_entry() of the
> empty segment list anyway, so desc->async_tx.phys, which is later
> programmed as the current descriptor, is derived from the list head
> rather than from a segment. For DMA_MEM_TO_DEV, the SOP and EOP bits are
> also set through pointers that do not point at a segment.
>
> Fail the preparation when no segment was allocated.
>
> Fixes: c0bba3a99f07 ("dmaengine: vdma: Add Support for Xilinx AXI Direct Memory Access Engine")
> Fixes: 6ccd692bfb7f ("dmaengine: xilinx_dma: Add Xilinx AXI MCDMA Engine driver support")
> Fixes: 38433a6fdfb7 ("dmaengine: xilinx_dma: Support descriptor setup from dma_vecs")
> Assisted-by: Claude:claude-fable-5-1
> Signed-off-by: Jeff C. Jensen <kernel@xxxxxxxxxxx>
> ---
Reviewed-by: Frank Li <Frank.Li@xxxxxxx>
> drivers/dma/xilinx/xilinx_dma.c | 9 +++++++++
> 1 file changed, 9 insertions(+)
>
> diff --git a/drivers/dma/xilinx/xilinx_dma.c b/drivers/dma/xilinx/xilinx_dma.c
> index cffe7c6fa640..5ccc9f9d58a3 100644
> --- a/drivers/dma/xilinx/xilinx_dma.c
> +++ b/drivers/dma/xilinx/xilinx_dma.c
> @@ -2305,6 +2305,9 @@ static struct dma_async_tx_descriptor *xilinx_dma_prep_peripheral_dma_vec(
> }
> }
>
> + if (list_empty(&desc->segments))
> + goto error;
> +
> head = list_first_entry(&desc->segments, struct xilinx_axidma_tx_segment, node);
> desc->async_tx.phys = head->phys;
>
> @@ -2406,6 +2409,9 @@ static struct dma_async_tx_descriptor *xilinx_dma_prep_slave_sg(
> }
> }
>
> + if (list_empty(&desc->segments))
> + goto error;
> +
> segment = list_first_entry(&desc->segments,
> struct xilinx_axidma_tx_segment, node);
> desc->async_tx.phys = segment->phys;
> @@ -2613,6 +2619,9 @@ xilinx_mcdma_prep_slave_sg(struct dma_chan *dchan, struct scatterlist *sgl,
> }
> }
>
> + if (list_empty(&desc->segments))
> + goto error;
> +
> segment = list_first_entry(&desc->segments,
> struct xilinx_aximcdma_tx_segment, node);
> desc->async_tx.phys = segment->phys;
>
> --
> 2.43.0
>