dmaengine: ptdma: check for null desc before calling pt_cmd_callback
authorEric Pilmore <epilmore@gigaio.com>
Fri, 10 Feb 2023 07:51:43 +0000 (23:51 -0800)
committerVinod Koul <vkoul@kernel.org>
Thu, 16 Feb 2023 13:15:48 +0000 (18:45 +0530)
Resolves a panic that can occur on AMD systems, typically during host
shutdown, after the PTDMA driver had been exercised. The issue was
the pt_issue_pending() function is mistakenly assuming that there will
be at least one descriptor in the Submitted queue when the function
is called. However, it is possible that both the Submitted and Issued
queues could be empty, which could result in pt_cmd_callback() being
mistakenly called with a NULL pointer.
Ref: Bugzilla Bug 216856.

Fixes: 6fa7e0e836e2 ("dmaengine: ptdma: fix concurrency issue with multiple dma transfer")
Signed-off-by: Eric Pilmore <epilmore@gigaio.com>
Link: https://lore.kernel.org/r/20230210075142.58253-1-epilmore@gigaio.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
drivers/dma/ptdma/ptdma-dmaengine.c

index cc22d162ce250095b06d23273ce1caa011a9cc6f..1aa65e5de0f3ad9bc0fa0907ebda8e8c0fe6d0ab 100644 (file)
@@ -254,7 +254,7 @@ static void pt_issue_pending(struct dma_chan *dma_chan)
        spin_unlock_irqrestore(&chan->vc.lock, flags);
 
        /* If there was nothing active, start processing */
-       if (engine_is_idle)
+       if (engine_is_idle && desc)
                pt_cmd_callback(desc, 0);
 }