[PATCH 3/3] x86: Let extend_brk return a NULL pointer instead of just BUG_ON.
From: Konrad Rzeszutek Wilk
Date: Tue Jul 31 2012 - 06:52:02 EST
The callers of this function (dmi_alloc) and the various
Xen related ones can deal with a NULL pointer.
Suggested-by: Ian Campbell <Ian.Campbell@xxxxxxxxxx>
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@xxxxxxxxxx>
---
arch/x86/kernel/setup.c | 5 +++--
1 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
index 16be6dc..13d6c51 100644
--- a/arch/x86/kernel/setup.c
+++ b/arch/x86/kernel/setup.c
@@ -268,9 +268,10 @@ void * __init extend_brk(size_t size, size_t align)
BUG_ON(_brk_start == 0);
BUG_ON(align & mask);
- _brk_end = (_brk_end + mask) & ~mask;
- BUG_ON((char *)(_brk_end + size) > __brk_limit);
+ if ((char *)(((_brk_end + mask) & ~mask) + size) > __brk_limit)
+ return NULL;
+ _brk_end = (_brk_end + mask) & ~mask;
ret = (void *)_brk_end;
_brk_end += size;
--
1.7.7.6
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/