arm64: early_alloc: Fix check for allocation failure
PATCH 1/1 arm64: early_alloc: Fix check for allocation failure
In early_alloc we check if the memblock_alloc failed by checking the virtual address of the result, which will never fail. This patch fixes it to check the actual result for failure.
--- arch/arm64/mm/mmu.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
arch/arm64/mm/mmu.c +6 -2
@@ -64,8 +64,12 @@ EXPORT_SYMBOL(phys_mem_access_prot);static void __init *early_alloc (unsigned long sz) { -void *ptr =__va (memblock_alloc (sz, sz)); -BUG_ON (!ptr); +phys_addr_t phys; +void *ptr; + + phys =memblock_alloc (sz, sz); +BUG_ON (!phys); + ptr =__va (phys);memset (ptr,0 , sz);return ptr; }
Signature · 1 line
1.7.9.5
PATCH 1/1 arm64: early_alloc: Fix check for allocation failure
Quoted 19 lines · Suzuki K. Poulose
In
early_allocwe check if thememblock_allocfailed by checking the virtual address of the result, which will never fail. This patch fixes it to check the actual result for failure.Cc Catalin Marinas <[email protected]>Cc Will Deacon <[email protected]>Signed-off-by Suzuki K. Poulose <[email protected]>--- arch/arm64/mm/mmu.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)arch/arm64/mm/mmu.c +0
-0@@ -64,8 +64,12 @@ EXPORT_SYMBOL(phys_mem_access_prot);static void __init *early_alloc (unsigned long sz) {
arch/arm64/mm/mmu.c EXPORT_SYMBOL(phys_mem_access_prot); · line 74
Quoted 10 lines
arch/arm64/mm/mmu.c +6
-2-void *ptr =__va (memblock_alloc (sz, sz)); -BUG_ON (!ptr); +phys_addr_t phys; +void *ptr; + + phys =memblock_alloc (sz, sz); +BUG_ON (!phys); + ptr =__va (phys);memset (ptr,0 , sz);return ptr;
Haha, oops! I guess we don't tend to see failures that early on, but the fix is correct:
Will
PATCH 1/1 arm64: early_alloc: Fix check for allocation failure
In reply to Suzuki K. PouloseQuoted 7 lines · Suzuki K. Poulose
In
early_allocwe check if thememblock_allocfailed by checking the virtual address of the result, which will never fail. This patch fixes it to check the actual result for failure.Cc Catalin Marinas <[email protected]>Cc Will Deacon <[email protected]>Signed-off-by Suzuki K. Poulose <[email protected]>
Applied. Thanks.
Signature · 1 line
Catalin