Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp465017ybl; Tue, 28 Jan 2020 06:23:30 -0800 (PST) X-Google-Smtp-Source: APXvYqyZQtjodXoGPobcxlA0gL98tQEI9Vuc3yA7FRR7CoXa6Izz8r+nJl73u97xxtoT9rc9yQBZ X-Received: by 2002:aca:458:: with SMTP id 85mr3082302oie.56.1580221410281; Tue, 28 Jan 2020 06:23:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580221410; cv=none; d=google.com; s=arc-20160816; b=A3eb6RILQVf+ggnBUVnYirBfhmRUIRRw6lss2aMKO8fzBZ0euxTnhz/FDD9VGqvf6d 81l8pGttBBzXcOs3woGIMcze0ZVamkXhMIQ4l4CixMNzpLmyAIFBRzfaFYfKnGBrcU2g SM/OHfUW/zh+F+mu7WX5GKbuM4SDiqpUUppfEBiDeqIGL5CxCE/v70yfD/J0fQLCa7k7 6WLDeWCXMk0IxiD8hMLqVZWJDXWA/fqsk1amKr886tOUOSO9up6eRHrW1FgSUHYT9Mbv JdtD8ar94VeKRuGLFpLH9Ce/2j2/xurVWDfqrSAIuKzqD7C9hz/7IpC6ZQ8B/yujmXvt +vfg== 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=4eMJmPe8xqopJnZV18tHuif+kixo0FSsfG23h3Jk8u8=; b=p6UJkWRB4jYbJQbbque5DbWUaVd+140/I3kQNksEDpRWfoi3cMP3DB6eq9IjEpf4pu I0j3ZHMkhMDnoHbS4MTLlVs64tSidqxngOB6W685+Im3Tn4PnC3W9n2mw70tj+WBupFm cyvlAtMttd++ViLv9C9kkI1BZssVhfeIXkgtCkL6mEHvWuOG6GKnYfd5uwtbMtEZLf+D LiTYA0RjY0VVAH/O7eBzEgW1wKdwRm5qKicNJX3PDI718IEKE8WBAsIUyeVdKc0/y2tS 0JuTo8Tyrg9ryXbHSJU7GQUVDWMx6HXc2gxHTlzpZ8SB/5YwPvsi1coEzj2gQrqQJRCv MrWg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Bxw55WST; 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 m24si866280otk.239.2020.01.28.06.23.18; Tue, 28 Jan 2020 06:23:30 -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=Bxw55WST; 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 S1731291AbgA1OVZ (ORCPT + 99 others); Tue, 28 Jan 2020 09:21:25 -0500 Received: from mail.kernel.org ([198.145.29.99]:46714 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731272AbgA1OVY (ORCPT ); Tue, 28 Jan 2020 09:21:24 -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 F3EC024691; Tue, 28 Jan 2020 14:21:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1580221283; bh=7m3fKvPOw1TUuYme9LEnc0AE6Udzj0eu0sWT5cbzFnI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Bxw55WSTY/ero4tn2D2hhlw0TDFljBuSXwzpWTnePOYuAflbZNazmfOOGXK8w5ORO wIxxQESp8k2aws0NpPrQjUYAT+oYAwstgAQ3G3uQK9eNVOCA7ZyVaIbCEzXHmeoY6/ oLi+fb6wWkQv435vF5Eyx9Baz+08V2REJ7MRFYP0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kevin Mitchell , Joerg Roedel , Sasha Levin Subject: [PATCH 4.9 163/271] iommu/amd: Make iommu_disable safer Date: Tue, 28 Jan 2020 15:05:12 +0100 Message-Id: <20200128135904.718482747@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200128135852.449088278@linuxfoundation.org> References: <20200128135852.449088278@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: Kevin Mitchell [ Upstream commit 3ddbe913e55516d3e2165d43d4d5570761769878 ] Make it safe to call iommu_disable during early init error conditions before mmio_base is set, but after the struct amd_iommu has been added to the amd_iommu_list. For example, this happens if firmware fails to fill in mmio_phys in the ACPI table leading to a NULL pointer dereference in iommu_feature_disable. Fixes: 2c0ae1720c09c ('iommu/amd: Convert iommu initialization to state machine') Signed-off-by: Kevin Mitchell Signed-off-by: Joerg Roedel Signed-off-by: Sasha Levin --- drivers/iommu/amd_iommu_init.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/iommu/amd_iommu_init.c b/drivers/iommu/amd_iommu_init.c index 9bb8d64b6f947..c113e46fdc3ab 100644 --- a/drivers/iommu/amd_iommu_init.c +++ b/drivers/iommu/amd_iommu_init.c @@ -383,6 +383,9 @@ static void iommu_enable(struct amd_iommu *iommu) static void iommu_disable(struct amd_iommu *iommu) { + if (!iommu->mmio_base) + return; + /* Disable command buffer */ iommu_feature_disable(iommu, CONTROL_CMDBUF_EN); -- 2.20.1