aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/iommu/intel-iommu.c26
1 files changed, 10 insertions, 16 deletions
diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c
index a22c86c867fa..52be7555b0df 100644
--- a/drivers/iommu/intel-iommu.c
+++ b/drivers/iommu/intel-iommu.c
@@ -1298,15 +1298,6 @@ static void free_dmar_iommu(struct intel_iommu *iommu)
1298 1298
1299 g_iommus[iommu->seq_id] = NULL; 1299 g_iommus[iommu->seq_id] = NULL;
1300 1300
1301 /* if all iommus are freed, free g_iommus */
1302 for (i = 0; i < g_num_of_iommus; i++) {
1303 if (g_iommus[i])
1304 break;
1305 }
1306
1307 if (i == g_num_of_iommus)
1308 kfree(g_iommus);
1309
1310 /* free context mapping */ 1301 /* free context mapping */
1311 free_context_table(iommu); 1302 free_context_table(iommu);
1312} 1303}
@@ -2461,7 +2452,7 @@ static int __init init_dmars(void)
2461 sizeof(struct deferred_flush_tables), GFP_KERNEL); 2452 sizeof(struct deferred_flush_tables), GFP_KERNEL);
2462 if (!deferred_flush) { 2453 if (!deferred_flush) {
2463 ret = -ENOMEM; 2454 ret = -ENOMEM;
2464 goto error; 2455 goto free_g_iommus;
2465 } 2456 }
2466 2457
2467 for_each_active_iommu(iommu, drhd) { 2458 for_each_active_iommu(iommu, drhd) {
@@ -2469,7 +2460,7 @@ static int __init init_dmars(void)
2469 2460
2470 ret = iommu_init_domains(iommu); 2461 ret = iommu_init_domains(iommu);
2471 if (ret) 2462 if (ret)
2472 goto error; 2463 goto free_iommu;
2473 2464
2474 /* 2465 /*
2475 * TBD: 2466 * TBD:
@@ -2479,7 +2470,7 @@ static int __init init_dmars(void)
2479 ret = iommu_alloc_root_entry(iommu); 2470 ret = iommu_alloc_root_entry(iommu);
2480 if (ret) { 2471 if (ret) {
2481 printk(KERN_ERR "IOMMU: allocate root entry failed\n"); 2472 printk(KERN_ERR "IOMMU: allocate root entry failed\n");
2482 goto error; 2473 goto free_iommu;
2483 } 2474 }
2484 if (!ecap_pass_through(iommu->ecap)) 2475 if (!ecap_pass_through(iommu->ecap))
2485 hw_pass_through = 0; 2476 hw_pass_through = 0;
@@ -2548,7 +2539,7 @@ static int __init init_dmars(void)
2548 ret = iommu_prepare_static_identity_mapping(hw_pass_through); 2539 ret = iommu_prepare_static_identity_mapping(hw_pass_through);
2549 if (ret) { 2540 if (ret) {
2550 printk(KERN_CRIT "Failed to setup IOMMU pass-through\n"); 2541 printk(KERN_CRIT "Failed to setup IOMMU pass-through\n");
2551 goto error; 2542 goto free_iommu;
2552 } 2543 }
2553 } 2544 }
2554 /* 2545 /*
@@ -2606,7 +2597,7 @@ static int __init init_dmars(void)
2606 2597
2607 ret = dmar_set_interrupt(iommu); 2598 ret = dmar_set_interrupt(iommu);
2608 if (ret) 2599 if (ret)
2609 goto error; 2600 goto free_iommu;
2610 2601
2611 iommu_set_root_entry(iommu); 2602 iommu_set_root_entry(iommu);
2612 2603
@@ -2615,17 +2606,20 @@ static int __init init_dmars(void)
2615 2606
2616 ret = iommu_enable_translation(iommu); 2607 ret = iommu_enable_translation(iommu);
2617 if (ret) 2608 if (ret)
2618 goto error; 2609 goto free_iommu;
2619 2610
2620 iommu_disable_protect_mem_regions(iommu); 2611 iommu_disable_protect_mem_regions(iommu);
2621 } 2612 }
2622 2613
2623 return 0; 2614 return 0;
2624error: 2615
2616free_iommu:
2625 for_each_active_iommu(iommu, drhd) 2617 for_each_active_iommu(iommu, drhd)
2626 free_dmar_iommu(iommu); 2618 free_dmar_iommu(iommu);
2627 kfree(deferred_flush); 2619 kfree(deferred_flush);
2620free_g_iommus:
2628 kfree(g_iommus); 2621 kfree(g_iommus);
2622error:
2629 return ret; 2623 return ret;
2630} 2624}
2631 2625