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=-9.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 012D3C2D0DB for ; Fri, 24 Jan 2020 10:00:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id CC1DA20709 for ; Fri, 24 Jan 2020 10:00:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1579860052; bh=uEHml99Vu7T5nMz6INsN49qJjRwyT1Zq+sMOwD2QEAI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=dEr20pM4C3K/ORNG8uUkXvbnoayrK5JnK8tiC14bbZI/OX6LOcnXNfT2LFt6sF6Zu ppkfSfh8lwZ3JsFJkcpvr5hby7KYvbozHhRWCXbciUa5xpZ/+AJCbp/Smn99roeubd 0kzaRCmN+0+J9Jra5xRzYBCUvdKzm/U+/8Sf9Dtk= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388804AbgAXKAw (ORCPT ); Fri, 24 Jan 2020 05:00:52 -0500 Received: from mail.kernel.org ([198.145.29.99]:36296 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733301AbgAXKAv (ORCPT ); Fri, 24 Jan 2020 05:00:51 -0500 Received: from localhost (unknown [145.15.244.15]) (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 5A66520709; Fri, 24 Jan 2020 10:00:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1579860051; bh=uEHml99Vu7T5nMz6INsN49qJjRwyT1Zq+sMOwD2QEAI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aWsa+Mz/gZ2TDnAWOQ2Ihg+RDlqX94xg4W+TlGT7jbiYUzcBCjizJbWAGa0P3SysO R/U99nMd50mJnZX6fsmitO2Aby3WXZ8cuSAABOR6KaJQA9ffsqz9OMBcieL/ZQRWQB rgwfudzqE68DQELsjgs+RGLSRQU4AtMZguHma0Qk= 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.14 248/343] iommu/amd: Make iommu_disable safer Date: Fri, 24 Jan 2020 10:31:06 +0100 Message-Id: <20200124092952.707763954@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200124092919.490687572@linuxfoundation.org> References: <20200124092919.490687572@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@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 6a3cf4d0bd5e3..4d2920988d607 100644 --- a/drivers/iommu/amd_iommu_init.c +++ b/drivers/iommu/amd_iommu_init.c @@ -420,6 +420,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