if (flags & NO_EXEC_MAPPINGS)
                        pmdval |= PMD_TABLE_PXN;
-               BUG_ON(!pgtable_alloc);
                pte_phys = pgtable_alloc(PAGE_SHIFT);
                __pmd_populate(pmdp, pte_phys, pmdval);
                pmd = READ_ONCE(*pmdp);
 
                if (flags & NO_EXEC_MAPPINGS)
                        pudval |= PUD_TABLE_PXN;
-               BUG_ON(!pgtable_alloc);
                pmd_phys = pgtable_alloc(PMD_SHIFT);
                __pud_populate(pudp, pmd_phys, pudval);
                pud = READ_ONCE(*pudp);
 
                if (flags & NO_EXEC_MAPPINGS)
                        p4dval |= P4D_TABLE_PXN;
-               BUG_ON(!pgtable_alloc);
                pud_phys = pgtable_alloc(PUD_SHIFT);
                __p4d_populate(p4dp, pud_phys, p4dval);
                p4d = READ_ONCE(*p4dp);
        phys &= PAGE_MASK;
        addr = virt & PAGE_MASK;
        end = PAGE_ALIGN(virt + size);
+       BUG_ON(!pgtable_alloc);
 
        do {
                next = pgd_addr_end(addr, end);