dmaengine: dw-axi-dmac: fix null dereference when pointer first is null
authorColin Ian King <colin.king@canonical.com>
Wed, 8 May 2019 22:33:29 +0000 (23:33 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 25 Jun 2019 03:35:55 +0000 (11:35 +0800)
commite478abd4ebf720121cbc5ab4bf14bd4b1cbe2f3a
tree050de91369526db27af4f555d6ed4254534a2697
parent4c21b761b40e082c6630f684e23c45bfbd5ef254
dmaengine: dw-axi-dmac: fix null dereference when pointer first is null

[ Upstream commit 0788611c9a0925c607de536b2449de5ed98ef8df ]

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")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Vinod Koul <vkoul@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c