diff options
author | Kevin Mitchell <kevmitch@arista.com> | 2019-06-13 00:52:03 +0300 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2020-01-29 12:21:45 +0300 |
commit | 1a49e9e284199fad043bd81628435b0bae714afb (patch) | |
tree | 15b07bddeaeccbe241972b103c9e6828205c2e8b | |
parent | eddade2cae78d54e9f1a3d026bae39af02182941 (diff) | |
download | linux-1a49e9e284199fad043bd81628435b0bae714afb.tar.xz |
iommu/amd: Make iommu_disable safer
[ 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 <kevmitch@arista.com>
Signed-off-by: Joerg Roedel <jroedel@suse.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
-rw-r--r-- | drivers/iommu/amd_iommu_init.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/drivers/iommu/amd_iommu_init.c b/drivers/iommu/amd_iommu_init.c index 6a69b5bb231f..036fb186a3be 100644 --- a/drivers/iommu/amd_iommu_init.c +++ b/drivers/iommu/amd_iommu_init.c @@ -360,6 +360,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); |