Skip to content

Commit

Permalink
arm64: early_alloc: Fix check for allocation failure
Browse files Browse the repository at this point in the history
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.

Acked-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Suzuki K. Poulose <suzuki.poulose@arm.com>
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
  • Loading branch information
Suzuki K. Poulose authored and Catalin Marinas committed Nov 25, 2015
1 parent 1ec2183 commit 7142392
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions arch/arm64/mm/mmu.c
Original file line number Diff line number Diff line change
@@ -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;
}

0 comments on commit 7142392

Please sign in to comment.