]> xenbits.xensource.com Git - people/dwmw2/xen.git/commitdiff
AMD/IOMMU: free more memory when cleaning up after error
authorJan Beulich <jbeulich@suse.com>
Fri, 26 Jul 2019 09:00:50 +0000 (11:00 +0200)
committerJan Beulich <jbeulich@suse.com>
Fri, 26 Jul 2019 09:00:50 +0000 (11:00 +0200)
The interrupt remapping in-use bitmaps were leaked in all cases. The
ring buffers and the mapping of the MMIO space were leaked for any IOMMU
that hadn't been enabled yet.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Brian Woods <brian.woods@amd.com>
master commit: 6ae22e7aac8fb0d39318eb27eab439dd97521174
master date: 2019-07-22 11:59:01 +0200

xen/drivers/passthrough/amd/iommu_init.c
xen/drivers/passthrough/amd/iommu_intr.c

index e4b267ea61b69b934c22dffd685e1fa02cfaae51..6c75c2daee060de49fc9906b281996e0c985e393 100644 (file)
@@ -1073,13 +1073,12 @@ static void __init amd_iommu_init_cleanup(void)
     {
         list_del(&iommu->list);
         if ( iommu->enabled )
-        {
             disable_iommu(iommu);
-            deallocate_ring_buffer(&iommu->cmd_buffer);
-            deallocate_ring_buffer(&iommu->event_log);
-            deallocate_ring_buffer(&iommu->ppr_log);
-            unmap_iommu_mmio_region(iommu);
-        }
+
+        deallocate_ring_buffer(&iommu->cmd_buffer);
+        deallocate_ring_buffer(&iommu->event_log);
+        deallocate_ring_buffer(&iommu->ppr_log);
+        unmap_iommu_mmio_region(iommu);
         xfree(iommu);
     }
 
index dad2d1e5ab93cad8473ee2dcab53c9a94c28c290..d4ff8c18f93888aebd5298fd4af8fd3a1f3b9805 100644 (file)
@@ -610,6 +610,8 @@ int __init amd_iommu_free_intremap_table(
 {
     void *tb = ivrs_mapping->intremap_table;
 
+    XFREE(ivrs_mapping->intremap_inuse);
+
     if ( tb )
     {
         __free_amd_iommu_tables(tb, INTREMAP_TABLE_ORDER);