Messages in this thread | | | Subject | Re: [PATCH 2/2] iommu/vt-d: Check if domain->pgd was allocated | From | Lu Baolu <> | Date | Fri, 19 Jul 2019 17:15:21 +0800 |
| |
Hi,
On 7/17/19 5:38 AM, Dmitry Safonov wrote: > 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>
This looks good to me. Thank you!
Reviewed-by: Lu Baolu <baolu.lu@linux.intel.com>
Best regards, Baolu
> Cc: iommu@lists.linux-foundation.org > Signed-off-by: Dmitry Safonov <dima@arista.com> > --- > drivers/iommu/intel-iommu.c | 8 +++++--- > 1 file changed, 5 insertions(+), 3 deletions(-) > > diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c > index 6d1510284d21..698cc40355ef 100644 > --- a/drivers/iommu/intel-iommu.c > +++ b/drivers/iommu/intel-iommu.c > @@ -1835,7 +1835,6 @@ static inline int guestwidth_to_adjustwidth(int gaw) > > 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); > @@ -1843,9 +1842,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); > } >
| |