intel-iommu: Fix use after release during device attach
authorJan Kiszka <jan.kiszka@siemens.com>
Tue, 2 Nov 2010 07:05:51 +0000 (08:05 +0100)
committerDavid Woodhouse <David.Woodhouse@intel.com>
Mon, 17 Jan 2011 16:21:42 +0000 (16:21 +0000)
Obtain the new pgd pointer before releasing the page containing this
value.

Cc: stable@kernel.org
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Reviewed-by: Sheng Yang <sheng@linux.intel.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
drivers/pci/intel-iommu.c

index 4789f8e8bf7ad91cae0b0a1043349ac96ea5fa64..35463ddf10a1605dec3f0d64d518e31518bf101c 100644 (file)
@@ -3627,9 +3627,9 @@ static int intel_iommu_attach_device(struct iommu_domain *domain,
 
                pte = dmar_domain->pgd;
                if (dma_pte_present(pte)) {
-                       free_pgtable_page(dmar_domain->pgd);
                        dmar_domain->pgd = (struct dma_pte *)
                                phys_to_virt(dma_pte_addr(pte));
+                       free_pgtable_page(pte);
                }
                dmar_domain->agaw--;
        }