linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Philipp Hachtmann <phacht@linux.vnet.ibm.com>
To: akpm@linux-foundation.org, jiang.liu@huawei.com
Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org,
	iamjoonsoo.kim@lge.com, hannes@cmpxchg.org,
	tangchen@cn.fujitsu.com, tj@kernel.org, toshi.kani@hp.com,
	Philipp Hachtmann <phacht@linux.vnet.ibm.com>
Subject: [PATCH 1/2] mm, nobootmem: Add return value check in __alloc_memory_core_early()
Date: Tue,  7 Jan 2014 16:16:13 +0100	[thread overview]
Message-ID: <1389107774-54978-2-git-send-email-phacht@linux.vnet.ibm.com> (raw)
In-Reply-To: <1389107774-54978-1-git-send-email-phacht@linux.vnet.ibm.com>

When memblock_reserve() fails because memblock.reserved.regions cannot
be resized, the caller (e.g. alloc_bootmem()) is not informed of the
failed allocation. Therefore alloc_bootmem() silently returns the same
pointer again and again.
This patch adds a check for the return value of memblock_reserve() in
__alloc_memory_core().

Signed-off-by: Philipp Hachtmann <phacht@linux.vnet.ibm.com>
---
 mm/nobootmem.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/mm/nobootmem.c b/mm/nobootmem.c
index 2c254d3..3a7e14d 100644
--- a/mm/nobootmem.c
+++ b/mm/nobootmem.c
@@ -45,7 +45,9 @@ static void * __init __alloc_memory_core_early(int nid, u64 size, u64 align,
 	if (!addr)
 		return NULL;
 
-	memblock_reserve(addr, size);
+	if (memblock_reserve(addr, size))
+		return NULL;
+
 	ptr = phys_to_virt(addr);
 	memset(ptr, 0, size);
 	/*
-- 
1.8.4.5

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

  reply	other threads:[~2014-01-07 15:17 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-07 15:16 [PATCH 0/2] Small fixes to memblock and nobootmem Philipp Hachtmann
2014-01-07 15:16 ` Philipp Hachtmann [this message]
2014-01-07 15:19   ` [PATCH 1/2] mm, nobootmem: Add return value check in __alloc_memory_core_early() Tejun Heo
2014-01-07 15:16 ` [PATCH 2/2] mm: free memblock.memory in free_all_bootmem Philipp Hachtmann
2014-01-07 15:23   ` Tejun Heo
2014-01-08  4:08   ` Jianguo Wu
2014-01-08 13:42     ` Philipp Hachtmann
2014-01-08 23:30       ` Yinghai Lu

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=1389107774-54978-2-git-send-email-phacht@linux.vnet.ibm.com \
    --to=phacht@linux.vnet.ibm.com \
    --cc=akpm@linux-foundation.org \
    --cc=hannes@cmpxchg.org \
    --cc=iamjoonsoo.kim@lge.com \
    --cc=jiang.liu@huawei.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=tangchen@cn.fujitsu.com \
    --cc=tj@kernel.org \
    --cc=toshi.kani@hp.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox