intel-iommu: Fix use after release during device attach
[linux-2.6-block.git] / 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--;
        }