From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8C8ECC43613 for ; Mon, 24 Jun 2019 10:03:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5802720848 for ; Mon, 24 Jun 2019 10:03:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1561370601; bh=CpjiAQxxGhskeVbGZi9ELuGE30tiEiIXdWgK6Pov1Gc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=FJiBmADlEaWMNq/vqwU9OzbZOFBeE1QzZl939iardgIr8RIUqgq3CWPaiqTjZEJvR pBAy3AbAGpkQzuiJzRewfiQVVk40eI03TmBbhiALng+uIak5SWLHu4QmP0xtgX6H9U NPOkQEE+kFAxAoVnbx7nx+Pjcdu84h6B5ErZZxrs= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729557AbfFXKDU (ORCPT ); Mon, 24 Jun 2019 06:03:20 -0400 Received: from mail.kernel.org ([198.145.29.99]:34566 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729524AbfFXKDO (ORCPT ); Mon, 24 Jun 2019 06:03:14 -0400 Received: from localhost (f4.8f.5177.ip4.static.sl-reverse.com [119.81.143.244]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 01CC0205ED; Mon, 24 Jun 2019 10:03:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1561370593; bh=CpjiAQxxGhskeVbGZi9ELuGE30tiEiIXdWgK6Pov1Gc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=F0uG5DQa6L8n2RGuELqicuXeaJWUNrnCkDyYDIYYK2xkgX51hXw/3k86cSUxKrYN/ BSdauBL0fFzEwSbZ4ai4gXorP9P1Kd8W1wMPPI7dBO/VKuvEm8g4aOshfuz1g07quK Leh+YGpGTlFwGoz87hkUSU2J4KFfROedqQrCPuJ8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Colin Ian King , Vinod Koul , Sasha Levin Subject: [PATCH 4.19 31/90] dmaengine: dw-axi-dmac: fix null dereference when pointer first is null Date: Mon, 24 Jun 2019 17:56:21 +0800 Message-Id: <20190624092316.334690590@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190624092313.788773607@linuxfoundation.org> References: <20190624092313.788773607@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ 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 Signed-off-by: Vinod Koul Signed-off-by: Sasha Levin --- drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c b/drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c index c4eb55e3011c..c05ef7f1d7b6 100644 --- a/drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c +++ b/drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c @@ -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; } -- 2.20.1