iommu/vt-d: Avoid freeing virtual machine domain in free_dmar_iommu()
authorJiang Liu <jiang.liu@linux.intel.com>
Fri, 11 Jul 2014 06:19:31 +0000 (14:19 +0800)
committerJoerg Roedel <jroedel@suse.de>
Wed, 23 Jul 2014 14:04:47 +0000 (16:04 +0200)
Virtual machine domains are created by intel_iommu_domain_init() and
should be destroyed by intel_iommu_domain_destroy(). So avoid freeing
virtual machine domain data structure in free_dmar_iommu() when
doamin->iommu_count reaches zero, otherwise it may cause invalid
memory access because the IOMMU framework still holds references
to the domain structure.

Signed-off-by: Jiang Liu <jiang.liu@linux.intel.com>
Signed-off-by: Joerg Roedel <jroedel@suse.de>
drivers/iommu/intel-iommu.c

index 0984fa58d87274302a8b9c57e8ee7f54c9c47b20..5d7383775bf1cc689ae39f98a488575ae92a5ae0 100644 (file)
@@ -1480,7 +1480,8 @@ static void free_dmar_iommu(struct intel_iommu *iommu)
 
                        domain = iommu->domains[i];
                        clear_bit(i, iommu->domain_ids);
-                       if (domain_detach_iommu(domain, iommu) == 0)
+                       if (domain_detach_iommu(domain, iommu) == 0 &&
+                           !domain_type_is_vm(domain))
                                domain_exit(domain);
                }
        }
This page took 0.025494 seconds and 5 git commands to generate.