@@ -1298,15 +1298,6 @@ static void free_dmar_iommu(struct intel_iommu *iommu)
1298
1298
1299
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
1301
/* free context mapping */
1311
1302
free_context_table (iommu );
1312
1303
}
@@ -2461,15 +2452,15 @@ static int __init init_dmars(void)
2461
2452
sizeof (struct deferred_flush_tables ), GFP_KERNEL );
2462
2453
if (!deferred_flush ) {
2463
2454
ret = - ENOMEM ;
2464
- goto error ;
2455
+ goto free_g_iommus ;
2465
2456
}
2466
2457
2467
2458
for_each_active_iommu (iommu , drhd ) {
2468
2459
g_iommus [iommu -> seq_id ] = iommu ;
2469
2460
2470
2461
ret = iommu_init_domains (iommu );
2471
2462
if (ret )
2472
- goto error ;
2463
+ goto free_iommu ;
2473
2464
2474
2465
/*
2475
2466
* TBD:
@@ -2479,7 +2470,7 @@ static int __init init_dmars(void)
2479
2470
ret = iommu_alloc_root_entry (iommu );
2480
2471
if (ret ) {
2481
2472
printk (KERN_ERR "IOMMU: allocate root entry failed\n" );
2482
- goto error ;
2473
+ goto free_iommu ;
2483
2474
}
2484
2475
if (!ecap_pass_through (iommu -> ecap ))
2485
2476
hw_pass_through = 0 ;
@@ -2548,7 +2539,7 @@ static int __init init_dmars(void)
2548
2539
ret = iommu_prepare_static_identity_mapping (hw_pass_through );
2549
2540
if (ret ) {
2550
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
2598
ret = dmar_set_interrupt (iommu );
2608
2599
if (ret )
2609
- goto error ;
2600
+ goto free_iommu ;
2610
2601
2611
2602
iommu_set_root_entry (iommu );
2612
2603
@@ -2615,17 +2606,20 @@ static int __init init_dmars(void)
2615
2606
2616
2607
ret = iommu_enable_translation (iommu );
2617
2608
if (ret )
2618
- goto error ;
2609
+ goto free_iommu ;
2619
2610
2620
2611
iommu_disable_protect_mem_regions (iommu );
2621
2612
}
2622
2613
2623
2614
return 0 ;
2624
- error :
2615
+
2616
+ free_iommu :
2625
2617
for_each_active_iommu (iommu , drhd )
2626
2618
free_dmar_iommu (iommu );
2627
2619
kfree (deferred_flush );
2620
+ free_g_iommus :
2628
2621
kfree (g_iommus );
2622
+ error :
2629
2623
return ret ;
2630
2624
}
2631
2625
0 commit comments