Skip to contentSkip to conversation

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

PATCH Applied Colin King 2 participants 2 messages May 8, 2019 – May 21, 2019

Subsystems (3)
lore
Share & tools
lore

Colin King

author
#0 lore raw

PATCH 1/1 dma: dw-axi-dmac: fix null dereference when pointer first is null

From: Colin Ian King <[email protected]>

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 1fe20f1b8454 ("dmaengine: Introduce DW AXI DMAC driver")
---
 drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c +2 -1
index b2ac1d2c5b86..a1ce307c502f 100644
@@ -512,7 +512,8 @@ dma_chan_prep_dma_memcpy(struct dma_chan *dchan, dma_addr_t dst_adr,
 	return vchan_tx_prep(&chan->vc, &first->vd, flags);
 
 err_desc_get:
-	axi_desc_put(first);
+	if (first)
+		axi_desc_put(first);
 	return NULL;
 }
 
Signature · 1 line
2.20.1
maintainer Applied
#1 lore raw
Quoted 7 lines · Colin King

From: Colin Ian King <[email protected]>

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.

Applied, thanks

Signature · 1 line
~Vinod