diff mbox series

[v3,01/14] AMD/IOMMU: free more memory when cleaning up after error

Message ID 78aa4de3-f955-850f-9e1b-8711f2aa906f@suse.com (mailing list archive)
State New, archived
Headers show
Series [v3,01/14] AMD/IOMMU: free more memory when cleaning up after error | expand

Commit Message

Jan Beulich July 16, 2019, 4:35 p.m. UTC
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>
---
v3: New.

Comments

Andrew Cooper July 19, 2019, 3:02 p.m. UTC | #1
On 16/07/2019 17:35, Jan Beulich wrote:
> 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>
Woods, Brian July 19, 2019, 6:22 p.m. UTC | #2
On Tue, Jul 16, 2019 at 04:35:08PM +0000, Jan Beulich wrote:
> 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>

Acked-by: Brian Woods <brian.woods@amd.com>

> ---
> v3: New.
> 
> --- a/xen/drivers/passthrough/amd/iommu_init.c
> +++ b/xen/drivers/passthrough/amd/iommu_init.c
> @@ -1070,13 +1070,12 @@ static void __init amd_iommu_init_cleanu
>       {
>           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);
>       }
>   
> --- a/xen/drivers/passthrough/amd/iommu_intr.c
> +++ b/xen/drivers/passthrough/amd/iommu_intr.c
> @@ -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);
>
diff mbox series

Patch

--- a/xen/drivers/passthrough/amd/iommu_init.c
+++ b/xen/drivers/passthrough/amd/iommu_init.c
@@ -1070,13 +1070,12 @@  static void __init amd_iommu_init_cleanu
      {
          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);
      }
  
--- a/xen/drivers/passthrough/amd/iommu_intr.c
+++ b/xen/drivers/passthrough/amd/iommu_intr.c
@@ -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);