Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp8474813ybl; Thu, 16 Jan 2020 17:35:53 -0800 (PST) X-Google-Smtp-Source: APXvYqzhG/c7C04cbweVHRt/URZP6E3Pb5coRLxcMLEzCaCCyrW2YctaMRy1McpnBi9akNdi/33D X-Received: by 2002:a05:6808:b13:: with SMTP id s19mr1609296oij.119.1579224953103; Thu, 16 Jan 2020 17:35:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579224953; cv=none; d=google.com; s=arc-20160816; b=Uri8EBBI/LzBWTNWtYdXSd7bnWpa81NGhNIz/lSNhCYIwO9MHEDjRUEpLI4FoX5fVB iw98Vc6SlGnAR1KN+indqsCJqLqzdEB6UhgbM/3aOKSvJ5rdwL0UVhf7VynMGHXeVku5 +1jVCf9nG6Cw7+RmBU1NLHggJUihco9PUE+0me6BkXh9L/Ur6VJiGI18tzwHDy/sfyul 0Ep3zQFf0WZHUO1ssDH4F7hfY1T+wbES5LEWzlKXUxO3v8TZ5/N7PbaN3cR9QQQWEpjm vCXdoV90lpMd/sAQhRMXSz78wlAk6TZqnRrWHW39x51tEESInNaoeeWlLR+QylstmWt1 JvgQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=6Y3eonln0a1V72JPqAiRJkFJi20Q90rn6KNwdIeM6RI=; b=uBKwGx5yY/p6beYxQ+kpd1UHLmJho1qappY8rITbjp8dXn8gygNF/zN/A5SY0i8e75 4rcZBCpIAxYOhWcr1h+AL37YQq9Ak4zmis4gicVlq2+7CfPkaN6mY0CzlaBk5AsaNmxU s74vbl5j3iOLLIrn+/Sz6aONgqPPmzbDPzOMtqPAGspArWiRJY9rTKvL1W9NtQU40IJt 9TMjgYURAPxMDC9lkMK5P0aCUP2P3yccCmXLLJgpIpCAWAEO8nRapYIwAHQ6n9wUcRZs dBfxtm7synfbwBYlgIPXBmMMe9O/DsdRs1/re3cX+yxEfzi6iaZ/QXTwzb5lhQuN93eB Do3w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Ftn84ud6; 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 e22si13848768oiy.124.2020.01.16.17.35.41; Thu, 16 Jan 2020 17:35:53 -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; dkim=pass header.i=@kernel.org header.s=default header.b=Ftn84ud6; 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 S2390021AbgAPX1R (ORCPT + 99 others); Thu, 16 Jan 2020 18:27:17 -0500 Received: from mail.kernel.org ([198.145.29.99]:58172 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387585AbgAPX1A (ORCPT ); Thu, 16 Jan 2020 18:27:00 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (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 F2FDD20684; Thu, 16 Jan 2020 23:26:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1579217219; bh=qWOkWTZDvoUQZWOJhFV2LbB6L4U3PuOYfjsuKkBo8X0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ftn84ud6IdNM0LygXEcMgvsobP19oyW15lmM71sRwcXMBkrlhKtBBWbDsUCu6TU++ DeFYOVhwmWbXtmHYSoeY3TBSytmsbnpb1FSROmdGG3kpkROm2cZvMW7aIM3LQC3QWz 7bNVFlmz1UjfKn9rQT9xcIpHmdfZbxjLWgyTJrvY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Alexander Barabash , Dave Jiang , Vinod Koul , Sasha Levin Subject: [PATCH 5.4 197/203] ioat: ioat_alloc_ring() failure handling. Date: Fri, 17 Jan 2020 00:18:34 +0100 Message-Id: <20200116231801.362880214@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200116231745.218684830@linuxfoundation.org> References: <20200116231745.218684830@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 From: Alexander.Barabash@dell.com [ Upstream commit b0b5ce1010ffc50015eaec72b0028aaae3f526bb ] If dma_alloc_coherent() returns NULL in ioat_alloc_ring(), ring allocation must not proceed. Until now, if the first call to dma_alloc_coherent() in ioat_alloc_ring() returned NULL, the processing could proceed, failing with NULL-pointer dereferencing further down the line. Signed-off-by: Alexander Barabash Acked-by: Dave Jiang Link: https://lore.kernel.org/r/75e9c0e84c3345d693c606c64f8b9ab5@x13pwhopdag1307.AMER.DELL.COM Signed-off-by: Vinod Koul Signed-off-by: Sasha Levin --- drivers/dma/ioat/dma.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/dma/ioat/dma.c b/drivers/dma/ioat/dma.c index 1a422a8b43cf..18c011e57592 100644 --- a/drivers/dma/ioat/dma.c +++ b/drivers/dma/ioat/dma.c @@ -377,10 +377,11 @@ ioat_alloc_ring(struct dma_chan *c, int order, gfp_t flags) descs->virt = dma_alloc_coherent(to_dev(ioat_chan), SZ_2M, &descs->hw, flags); - if (!descs->virt && (i > 0)) { + if (!descs->virt) { int idx; for (idx = 0; idx < i; idx++) { + descs = &ioat_chan->descs[idx]; dma_free_coherent(to_dev(ioat_chan), SZ_2M, descs->virt, descs->hw); descs->virt = NULL; -- 2.20.1