Skip to content

Commit 305245a

Browse files
basuamdvinodkoul
authored andcommitted
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: 6565439 ("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>
1 parent 8dfa57a commit 305245a

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

drivers/dma/amd/ptdma/ptdma-dmaengine.c

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,9 @@ static void pt_cmd_callback_work(void *data, int err)
342342
struct pt_dma_chan *chan;
343343
unsigned long flags;
344344

345+
if (!desc)
346+
return;
347+
345348
dma_chan = desc->vd.tx.chan;
346349
chan = to_pt_chan(dma_chan);
347350

@@ -355,16 +358,14 @@ static void pt_cmd_callback_work(void *data, int err)
355358
desc->status = DMA_ERROR;
356359

357360
spin_lock_irqsave(&chan->vc.lock, flags);
358-
if (desc) {
359-
if (desc->status != DMA_COMPLETE) {
360-
if (desc->status != DMA_ERROR)
361-
desc->status = DMA_COMPLETE;
361+
if (desc->status != DMA_COMPLETE) {
362+
if (desc->status != DMA_ERROR)
363+
desc->status = DMA_COMPLETE;
362364

363-
dma_cookie_complete(tx_desc);
364-
dma_descriptor_unmap(tx_desc);
365-
} else {
366-
tx_desc = NULL;
367-
}
365+
dma_cookie_complete(tx_desc);
366+
dma_descriptor_unmap(tx_desc);
367+
} else {
368+
tx_desc = NULL;
368369
}
369370
spin_unlock_irqrestore(&chan->vc.lock, flags);
370371

0 commit comments

Comments
 (0)