From: Kevin Mitchell Date: Wed, 12 Jun 2019 21:52:03 +0000 (-0700) Subject: iommu/amd: Make iommu_disable safer X-Git-Tag: iommu-updates-v5.3^2~3 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=3ddbe913e55516d3e2165d43d4d5570761769878;p=users%2Fdwmw2%2Flinux.git iommu/amd: Make iommu_disable safer 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 --- diff --git a/drivers/iommu/amd_iommu_init.c b/drivers/iommu/amd_iommu_init.c index f977df90d2a49..df144dc6d8aca 100644 --- a/drivers/iommu/amd_iommu_init.c +++ b/drivers/iommu/amd_iommu_init.c @@ -418,6 +418,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);