[PATCH 04/22] ARM: mmu: panic when alloc_pte fails
Ahmad Fatoum
a.fatoum at pengutronix.de
Wed Aug 6 05:36:56 PDT 2025
We don't check the return value of alloc_pte for ARM32 PBL, but we do on ARM64
PBL as well as in barebox proper.
Let's unify behavior by panicing in alloc_pte right away if we run out of
memory.
Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
---
arch/arm/cpu/mmu_32.c | 3 +--
arch/arm/cpu/mmu_64.c | 6 +-----
2 files changed, 2 insertions(+), 7 deletions(-)
diff --git a/arch/arm/cpu/mmu_32.c b/arch/arm/cpu/mmu_32.c
index 848d2d2b8c0b..e631b741f107 100644
--- a/arch/arm/cpu/mmu_32.c
+++ b/arch/arm/cpu/mmu_32.c
@@ -83,8 +83,7 @@ static uint32_t *alloc_pte(void)
idx++;
- if (idx * PTE_SIZE >= ARM_EARLY_PAGETABLE_SIZE)
- return NULL;
+ BUG_ON(idx * PTE_SIZE >= ARM_EARLY_PAGETABLE_SIZE);
return get_ttb() + idx * PTE_SIZE;
}
diff --git a/arch/arm/cpu/mmu_64.c b/arch/arm/cpu/mmu_64.c
index 83738ed6ad0d..e2cc1a5caabd 100644
--- a/arch/arm/cpu/mmu_64.c
+++ b/arch/arm/cpu/mmu_64.c
@@ -46,8 +46,7 @@ static uint64_t *alloc_pte(void)
idx++;
- if (idx * GRANULE_SIZE >= ARM_EARLY_PAGETABLE_SIZE)
- return NULL;
+ BUG_ON(idx * GRANULE_SIZE >= ARM_EARLY_PAGETABLE_SIZE);
return (void *)get_ttb() + idx * GRANULE_SIZE;
}
@@ -109,9 +108,6 @@ static void split_block(uint64_t *pte, int level)
levelshift = level2shift(level + 1);
new_table = alloc_pte();
- if (!new_table)
- panic("Unable to allocate PTE\n");
-
for (i = 0; i < MAX_PTE_ENTRIES; i++) {
set_pte(&new_table[i], old_pte | (i << levelshift));
--
2.39.5
More information about the barebox
mailing list