Received: by 10.223.185.116 with SMTP id b49csp1097815wrg; Fri, 23 Feb 2018 11:54:19 -0800 (PST) X-Google-Smtp-Source: AH8x227pLSE/Hgeid33G1j62vc/LU25x6l8I1lq0NUBnoU1pJYEMnj8kyzHLhp25vhdoUQ8jZfWC X-Received: by 2002:a17:902:ad0a:: with SMTP id i10-v6mr2706816plr.130.1519415659754; Fri, 23 Feb 2018 11:54:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519415659; cv=none; d=google.com; s=arc-20160816; b=mLEwoYbzgsgQSsogu+7SG3hJATfTvF9OIE4oB9U9MzrMeJtIbOI5KzONquVY11isC7 2MgaxzxH7MqFxPMrNWPVCsgsGGjmSNBBlGkSryRUFH1g/4Le0d4L2Jr25eysYcgBzZ+m XMZ/8qaNQFOIOSioreuwF7jgbzyY1kuJjo35svpq7y0S4Q3qzpYYT578dRo7MqyrB81j t8KK4ToQBX3RbpT4WO2f/4TZtxHMl3lXEScZ9Y3epF/XSkbRlgOcFdZmK85SUasYiviI LnDK0kzoG+dmZr6razmNBDL1qaO9cW4e8RAu1BB7ov/45Ddrbuuaz0jN0uYnbiKeUDDs zbcQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=wUXa8+9aSCFrTDc0UjBCgAj3lhIGlS7blDRe2rBrvdQ=; b=V1HG0xIF+T4H2968MYYnx8CPi/NXx8ZmDK5JIt8WWVUKoUeo4XH/zfxx7gKSfhngMi wpH49a22bFxwazuU7YisMQ3oyXL8upKHP1IZvTkHd+twCVIQzpmzeOs6a2cJJiaIe3qa 2oDsshLWi7mSpEB/sHmG5ab5goBPk3ZjqAkcNX6z8flUJkYLKVpAjohNXDPyp7szKZlD HZnw05JL7ZGkOu8p36u0muFHDxsmSnZr6uaOVcGKH/vrU4CuTjLPcK39j9U3UrFLN4P0 qu9c7vqKiZ61gqbHFMcWAtolscX1LMsc8ddhm+73J8nRn+P4kSF/s9fVcPvNJYiUXYO4 p2Sg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j127si1885348pgc.653.2018.02.23.11.54.05; Fri, 23 Feb 2018 11:54:19 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933814AbeBWSpd (ORCPT + 99 others); Fri, 23 Feb 2018 13:45:33 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:43366 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933330AbeBWSpa (ORCPT ); Fri, 23 Feb 2018 13:45:30 -0500 Received: from localhost (LFbn-1-12258-90.w90-92.abo.wanadoo.fr [90.92.71.90]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id F23401294; Fri, 23 Feb 2018 18:45:29 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Gustavo A. R. Silva" , Ludovic Desroches , Vinod Koul , Sasha Levin Subject: [PATCH 4.9 073/145] dmaengine: at_hdmac: fix potential NULL pointer dereference in atc_prep_dma_interleaved Date: Fri, 23 Feb 2018 19:26:19 +0100 Message-Id: <20180223170734.126332999@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180223170724.669759283@linuxfoundation.org> References: <20180223170724.669759283@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: "Gustavo A. R. Silva" [ Upstream commit 62a277d43d47e74972de44d33bd3763e31992414 ] _xt_ is being dereferenced before it is null checked, hence there is a potential null pointer dereference. Fix this by moving the pointer dereference after _xt_ has been null checked. This issue was detected with the help of Coccinelle. Fixes: 4483320e241c ("dmaengine: Use Pointer xt after NULL check.") Signed-off-by: Gustavo A. R. Silva Acked-by: Ludovic Desroches Signed-off-by: Vinod Koul Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/dma/at_hdmac.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) --- a/drivers/dma/at_hdmac.c +++ b/drivers/dma/at_hdmac.c @@ -709,7 +709,7 @@ atc_prep_dma_interleaved(struct dma_chan unsigned long flags) { struct at_dma_chan *atchan = to_at_dma_chan(chan); - struct data_chunk *first = xt->sgl; + struct data_chunk *first; struct at_desc *desc = NULL; size_t xfer_count; unsigned int dwidth; @@ -721,6 +721,8 @@ atc_prep_dma_interleaved(struct dma_chan if (unlikely(!xt || xt->numf != 1 || !xt->frame_size)) return NULL; + first = xt->sgl; + dev_info(chan2dev(chan), "%s: src=%pad, dest=%pad, numf=%d, frame_size=%d, flags=0x%lx\n", __func__, &xt->src_start, &xt->dst_start, xt->numf,