All of lore.kernel.org
 help / color / mirror / Atom feed
From: will.deacon@arm.com (Will Deacon)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] arm64: early_alloc: Fix check for allocation failure
Date: Mon, 23 Nov 2015 15:24:36 +0000	[thread overview]
Message-ID: <20151123152436.GF4236@arm.com> (raw)
In-Reply-To: <1448041540-26229-1-git-send-email-suzuki.poulose@arm.com>

On Fri, Nov 20, 2015 at 05:45:40PM +0000, Suzuki K. Poulose wrote:
> 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.
> 
> Cc: Catalin Marinas <catalin.marinas@arm.com>
> Cc: Will Deacon <will.deacon@arm.com>
> Signed-off-by: Suzuki K. Poulose <suzuki.poulose@arm.com>
> ---
>  arch/arm64/mm/mmu.c |    8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c
> index e3f563c..e94c32b 100644
> --- a/arch/arm64/mm/mmu.c
> +++ b/arch/arm64/mm/mmu.c
> @@ -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;

Haha, oops! I guess we don't tend to see failures that early on, but the
fix is correct:

  Acked-by: Will Deacon <will.deacon@arm.com>

Will

  reply	other threads:[~2015-11-23 15:24 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-20 17:45 [PATCH] arm64: early_alloc: Fix check for allocation failure Suzuki K. Poulose
2015-11-23 15:24 ` Will Deacon [this message]
2015-11-25 12:14 ` Catalin Marinas

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20151123152436.GF4236@arm.com \
    --to=will.deacon@arm.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.