[PATCH] dmaengine: xilinx_dma: check done_list before list_last_entry() in cyclic mode
From: Ziheng Wei
Date: Thu Dec 03 2026 - 22:15:53 EST
In xilinx_dma_start_transfer(), when chan->pending_list is empty and
chan->cyclic is true, list_last_entry() is called on chan->done_list
without checking whether chan->done_list is empty. If done_list is empty,
list_last_entry() returns a bogus descriptor pointer derived from the
list head and the subsequent segment loop traverses invalid memory.
Guard the cyclic re-queueing path with !list_empty(&chan->done_list).
Found by LLM-assisted static analysis. Compile-tested on x86_64.
Fixes: f61d145999d6 ("dmaengine: xilinx: xilinx_dma: Fix residue calculation for cyclic DMA")
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Ziheng Wei <zihengw03@xxxxxxx>
---
drivers/dma/xilinx/xilinx_dma.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/dma/xilinx/xilinx_dma.c b/drivers/dma/xilinx/xilinx_dma.c
index b89f2c3c1..d4461003c 100644
--- a/drivers/dma/xilinx/xilinx_dma.c
+++ b/drivers/dma/xilinx/xilinx_dma.c
@@ -1618,7 +1618,7 @@ static void xilinx_dma_start_transfer(struct xilinx_dma_chan *chan)
return;
if (list_empty(&chan->pending_list)) {
- if (chan->cyclic) {
+ if (chan->cyclic && !list_empty(&chan->done_list)) {
struct xilinx_dma_tx_descriptor *desc;
struct list_head *entry;
base-commit: 97d73c8251226cf27cc6656b4c542869bb8c69fa
--
2.43.0