Skip to content

Commit

Permalink
iommu/vt-d: Avoid freeing virtual machine domain in free_dmar_iommu()
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Jiang Liu authored and Joerg Roedel committed Jul 23, 2014
1 parent 2a46ddf commit 129ad28
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion drivers/iommu/intel-iommu.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down

0 comments on commit 129ad28

Please sign in to comment.