Commit fdb4f05d authored by Joerg Roedel's avatar Joerg Roedel Committed by Greg Kroah-Hartman

x86/amd-iommu: Fix crash when request_mem_region fails

commit e82752d8 upstream.

When request_mem_region fails the error path tries to
disable the IOMMUs. This accesses the mmio-region which was
not allocated leading to a kernel crash. This patch fixes
the issue.
Signed-off-by: default avatarJoerg Roedel <joerg.roedel@amd.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 65aa78d8
...@@ -286,8 +286,12 @@ static u8 * __init iommu_map_mmio_space(u64 address) ...@@ -286,8 +286,12 @@ static u8 * __init iommu_map_mmio_space(u64 address)
{ {
u8 *ret; u8 *ret;
if (!request_mem_region(address, MMIO_REGION_LENGTH, "amd_iommu")) if (!request_mem_region(address, MMIO_REGION_LENGTH, "amd_iommu")) {
pr_err("AMD-Vi: Can not reserve memory region %llx for mmio\n",
address);
pr_err("AMD-Vi: This is a BIOS bug. Please contact your hardware vendor\n");
return NULL; return NULL;
}
ret = ioremap_nocache(address, MMIO_REGION_LENGTH); ret = ioremap_nocache(address, MMIO_REGION_LENGTH);
if (ret != NULL) if (ret != NULL)
...@@ -1313,7 +1317,7 @@ static int __init amd_iommu_init(void) ...@@ -1313,7 +1317,7 @@ static int __init amd_iommu_init(void)
ret = amd_iommu_init_dma_ops(); ret = amd_iommu_init_dma_ops();
if (ret) if (ret)
goto free; goto free_disable;
amd_iommu_init_api(); amd_iommu_init_api();
...@@ -1331,9 +1335,10 @@ static int __init amd_iommu_init(void) ...@@ -1331,9 +1335,10 @@ static int __init amd_iommu_init(void)
out: out:
return ret; return ret;
free: free_disable:
disable_iommus(); disable_iommus();
free:
amd_iommu_uninit_devices(); amd_iommu_uninit_devices();
free_pages((unsigned long)amd_iommu_pd_alloc_bitmap, free_pages((unsigned long)amd_iommu_pd_alloc_bitmap,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment