diff options
author | Dmitry Safonov <dima@arista.com> | 2019-07-16 17:38:06 -0400 |
---|---|---|
committer | Joerg Roedel <jroedel@suse.de> | 2019-07-22 11:43:06 -0400 |
commit | 3ee9eca760e7d0b68c55813243de66bbb499dc3b (patch) | |
tree | c9017fd789a53e515aac8a47e3849f0df6967fb9 /drivers/iommu/intel-iommu.c | |
parent | effa467870c7612012885df4e246bdb8ffd8e44c (diff) |
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>
Diffstat (limited to 'drivers/iommu/intel-iommu.c')
-rw-r--r-- | drivers/iommu/intel-iommu.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c index 72c6d647bec9..bdaed2da8a55 100644 --- a/drivers/iommu/intel-iommu.c +++ b/drivers/iommu/intel-iommu.c | |||
@@ -1890,7 +1890,6 @@ static int domain_init(struct dmar_domain *domain, struct intel_iommu *iommu, | |||
1890 | 1890 | ||
1891 | static void domain_exit(struct dmar_domain *domain) | 1891 | static void domain_exit(struct dmar_domain *domain) |
1892 | { | 1892 | { |
1893 | struct page *freelist; | ||
1894 | 1893 | ||
1895 | /* Remove associated devices and clear attached or cached domains */ | 1894 | /* Remove associated devices and clear attached or cached domains */ |
1896 | domain_remove_dev_info(domain); | 1895 | domain_remove_dev_info(domain); |
@@ -1898,9 +1897,12 @@ static void domain_exit(struct dmar_domain *domain) | |||
1898 | /* destroy iovas */ | 1897 | /* destroy iovas */ |
1899 | put_iova_domain(&domain->iovad); | 1898 | put_iova_domain(&domain->iovad); |
1900 | 1899 | ||
1901 | freelist = domain_unmap(domain, 0, DOMAIN_MAX_PFN(domain->gaw)); | 1900 | if (domain->pgd) { |
1901 | struct page *freelist; | ||
1902 | 1902 | ||
1903 | dma_free_pagelist(freelist); | 1903 | freelist = domain_unmap(domain, 0, DOMAIN_MAX_PFN(domain->gaw)); |
1904 | dma_free_pagelist(freelist); | ||
1905 | } | ||
1904 | 1906 | ||
1905 | free_domain_mem(domain); | 1907 | free_domain_mem(domain); |
1906 | } | 1908 | } |