Commit 0788611c authored by Colin Ian King's avatar Colin Ian King Committed by Vinod Koul

dmaengine: dw-axi-dmac: fix null dereference when pointer first is null

In the unlikely event that axi_desc_get returns a null desc in the
very first iteration of the while-loop the error exit path ends
up calling axi_desc_put on a null pointer 'first' and this causes
a null pointer dereference.  Fix this by adding a null check on
pointer 'first' before calling axi_desc_put.

Addresses-Coverity: ("Explicit null dereference")
Fixes: 1fe20f1b ("dmaengine: Introduce DW AXI DMAC driver")
Signed-off-by: default avatarColin Ian King <colin.king@canonical.com>
Signed-off-by: default avatarVinod Koul <vkoul@kernel.org>
parent 82748491
...@@ -512,6 +512,7 @@ dma_chan_prep_dma_memcpy(struct dma_chan *dchan, dma_addr_t dst_adr, ...@@ -512,6 +512,7 @@ dma_chan_prep_dma_memcpy(struct dma_chan *dchan, dma_addr_t dst_adr,
return vchan_tx_prep(&chan->vc, &first->vd, flags); return vchan_tx_prep(&chan->vc, &first->vd, flags);
err_desc_get: err_desc_get:
if (first)
axi_desc_put(first); axi_desc_put(first);
return NULL; return NULL;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment