diff options
author | 2025-04-21 17:12:15 +0530 | |
---|---|---|
committer | 2025-04-23 17:41:32 +0530 | |
commit | 305245a2e1d633e5f821178c98c6d6132cea2bdb (patch) | |
tree | 0ddc3139a51c8cb4fab3215222b9e2ec82b1cbf5 /drivers/dma | |
parent | dmaengine: idxd: Fix allowing write() from different address spaces (diff) | |
download | linux-rng-305245a2e1d633e5f821178c98c6d6132cea2bdb.tar.xz linux-rng-305245a2e1d633e5f821178c98c6d6132cea2bdb.zip |
dmaengine: ptdma: Move variable condition check to the first place and remove redundancy
The variable is dereferenced without first checking if it's null, leading
to the following warning: 'Variable dereferenced before check: desc.'
drivers/dma/amd/ptdma/ptdma-dmaengine.c: pt_cmd_callback_work()
warn: variable dereferenced before check 'desc'
Therefore, move the condition check for the 'desc' variable to the first
place and remove the redundant extra condition check.
Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
Closes: https://lore.kernel.org/all/bfa0a979-ce9f-422d-92c3-34921155d048@stanley.mountain/
Fixes: 656543989457 ("dmaengine: ptdma: Utilize the AE4DMA engine's multi-queue functionality")
Signed-off-by: Basavaraj Natikar <Basavaraj.Natikar@amd.com>
Link: https://lore.kernel.org/r/20250421114215.1687073-1-Basavaraj.Natikar@amd.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
Diffstat (limited to 'drivers/dma')
-rw-r--r-- | drivers/dma/amd/ptdma/ptdma-dmaengine.c | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/drivers/dma/amd/ptdma/ptdma-dmaengine.c b/drivers/dma/amd/ptdma/ptdma-dmaengine.c index 715ac3ae067b..81339664036f 100644 --- a/drivers/dma/amd/ptdma/ptdma-dmaengine.c +++ b/drivers/dma/amd/ptdma/ptdma-dmaengine.c @@ -342,6 +342,9 @@ static void pt_cmd_callback_work(void *data, int err) struct pt_dma_chan *chan; unsigned long flags; + if (!desc) + return; + dma_chan = desc->vd.tx.chan; chan = to_pt_chan(dma_chan); @@ -355,16 +358,14 @@ static void pt_cmd_callback_work(void *data, int err) desc->status = DMA_ERROR; spin_lock_irqsave(&chan->vc.lock, flags); - if (desc) { - if (desc->status != DMA_COMPLETE) { - if (desc->status != DMA_ERROR) - desc->status = DMA_COMPLETE; + if (desc->status != DMA_COMPLETE) { + if (desc->status != DMA_ERROR) + desc->status = DMA_COMPLETE; - dma_cookie_complete(tx_desc); - dma_descriptor_unmap(tx_desc); - } else { - tx_desc = NULL; - } + dma_cookie_complete(tx_desc); + dma_descriptor_unmap(tx_desc); + } else { + tx_desc = NULL; } spin_unlock_irqrestore(&chan->vc.lock, flags); |