diff options
| author | Joerg Roedel <joerg.roedel@amd.com> | 2010-05-28 08:26:48 -0400 |
|---|---|---|
| committer | Joerg Roedel <joerg.roedel@amd.com> | 2010-06-01 04:03:08 -0400 |
| commit | e82752d8b5a7e0a5e4d607fd8713549e2a4e2741 (patch) | |
| tree | 4bc5c676e46c26083e46b77907fe7d588831f4f5 | |
| parent | 1d61e73ab4c7470833241af888939a7aab2b0354 (diff) | |
x86/amd-iommu: Fix crash when request_mem_region fails
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.
Cc: stable@kernel.org
Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
| -rw-r--r-- | arch/x86/kernel/amd_iommu_init.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/arch/x86/kernel/amd_iommu_init.c b/arch/x86/kernel/amd_iommu_init.c index 3bacb4d0844c..1405346c62b4 100644 --- a/arch/x86/kernel/amd_iommu_init.c +++ b/arch/x86/kernel/amd_iommu_init.c | |||
| @@ -287,8 +287,12 @@ static u8 * __init iommu_map_mmio_space(u64 address) | |||
| 287 | { | 287 | { |
| 288 | u8 *ret; | 288 | u8 *ret; |
| 289 | 289 | ||
| 290 | if (!request_mem_region(address, MMIO_REGION_LENGTH, "amd_iommu")) | 290 | if (!request_mem_region(address, MMIO_REGION_LENGTH, "amd_iommu")) { |
| 291 | pr_err("AMD-Vi: Can not reserve memory region %llx for mmio\n", | ||
| 292 | address); | ||
| 293 | pr_err("AMD-Vi: This is a BIOS bug. Please contact your hardware vendor\n"); | ||
| 291 | return NULL; | 294 | return NULL; |
| 295 | } | ||
| 292 | 296 | ||
| 293 | ret = ioremap_nocache(address, MMIO_REGION_LENGTH); | 297 | ret = ioremap_nocache(address, MMIO_REGION_LENGTH); |
| 294 | if (ret != NULL) | 298 | if (ret != NULL) |
| @@ -1314,7 +1318,7 @@ static int __init amd_iommu_init(void) | |||
| 1314 | ret = amd_iommu_init_dma_ops(); | 1318 | ret = amd_iommu_init_dma_ops(); |
| 1315 | 1319 | ||
| 1316 | if (ret) | 1320 | if (ret) |
| 1317 | goto free; | 1321 | goto free_disable; |
| 1318 | 1322 | ||
| 1319 | amd_iommu_init_api(); | 1323 | amd_iommu_init_api(); |
| 1320 | 1324 | ||
| @@ -1332,9 +1336,10 @@ static int __init amd_iommu_init(void) | |||
| 1332 | out: | 1336 | out: |
| 1333 | return ret; | 1337 | return ret; |
| 1334 | 1338 | ||
| 1335 | free: | 1339 | free_disable: |
| 1336 | disable_iommus(); | 1340 | disable_iommus(); |
| 1337 | 1341 | ||
| 1342 | free: | ||
| 1338 | amd_iommu_uninit_devices(); | 1343 | amd_iommu_uninit_devices(); |
| 1339 | 1344 | ||
| 1340 | free_pages((unsigned long)amd_iommu_pd_alloc_bitmap, | 1345 | free_pages((unsigned long)amd_iommu_pd_alloc_bitmap, |
