mirror of
https://github.com/torvalds/linux.git
synced 2024-12-03 01:21:28 +00:00
iommu/vt-d: Check if domain->pgd was allocated
There is a couple of places where on domain_init() failure domain_exit() is called. While currently domain_init() can fail only if alloc_pgtable_page() has failed. Make domain_exit() check if domain->pgd present, before calling domain_unmap(), as it theoretically should crash on clearing pte entries in dma_pte_clear_level(). Cc: David Woodhouse <dwmw2@infradead.org> Cc: Joerg Roedel <joro@8bytes.org> Cc: Lu Baolu <baolu.lu@linux.intel.com> Cc: iommu@lists.linux-foundation.org Signed-off-by: Dmitry Safonov <dima@arista.com> Reviewed-by: Lu Baolu <baolu.lu@linux.intel.com> Signed-off-by: Joerg Roedel <jroedel@suse.de>
This commit is contained in:
parent
effa467870
commit
3ee9eca760
@ -1890,7 +1890,6 @@ static int domain_init(struct dmar_domain *domain, struct intel_iommu *iommu,
|
||||
|
||||
static void domain_exit(struct dmar_domain *domain)
|
||||
{
|
||||
struct page *freelist;
|
||||
|
||||
/* Remove associated devices and clear attached or cached domains */
|
||||
domain_remove_dev_info(domain);
|
||||
@ -1898,9 +1897,12 @@ static void domain_exit(struct dmar_domain *domain)
|
||||
/* destroy iovas */
|
||||
put_iova_domain(&domain->iovad);
|
||||
|
||||
freelist = domain_unmap(domain, 0, DOMAIN_MAX_PFN(domain->gaw));
|
||||
if (domain->pgd) {
|
||||
struct page *freelist;
|
||||
|
||||
dma_free_pagelist(freelist);
|
||||
freelist = domain_unmap(domain, 0, DOMAIN_MAX_PFN(domain->gaw));
|
||||
dma_free_pagelist(freelist);
|
||||
}
|
||||
|
||||
free_domain_mem(domain);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user