From: Borislav Petkov Date: Mon, 19 Oct 2015 09:17:46 +0000 (+0200) Subject: x86/setup/crash: Check memblock_reserve() retval X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=6f3760570e26eefc214e641b6daeddb7106240bb;p=GitHub%2FLineageOS%2Fandroid_kernel_motorola_exynos9610.git x86/setup/crash: Check memblock_reserve() retval memblock_reserve() can fail but the crashkernel reservation code doesn't check that and this can lead the user into believing that the crashkernel region was actually reserved. Make sure we check that return value and we exit early with a failure message in the error case. Signed-off-by: Borislav Petkov Reviewed-by: Dave Young Reviewed-by: Joerg Roedel Cc: Andrew Morton Cc: Andy Lutomirski Cc: H. Peter Anvin Cc: Jiri Kosina Cc: Juergen Gross Cc: Linus Torvalds Cc: Mark Salter Cc: Peter Zijlstra Cc: Thomas Gleixner Cc: WANG Chao Cc: jerry_hoemann@hp.com Link: http://lkml.kernel.org/r/1445246268-26285-7-git-send-email-bp@alien8.de Signed-off-by: Ingo Molnar --- diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c index d4788719a1e2..3f75297d5fd0 100644 --- a/arch/x86/kernel/setup.c +++ b/arch/x86/kernel/setup.c @@ -531,7 +531,11 @@ static int __init reserve_crashkernel_low(void) return -ENOMEM; } - memblock_reserve(low_base, low_size); + ret = memblock_reserve(low_base, low_size); + if (ret) { + pr_err("%s: Error reserving crashkernel low memblock.\n", __func__); + return ret; + } pr_info("Reserving %ldMB of low memory at %ldMB for crashkernel (System low RAM: %ldMB)\n", (unsigned long)(low_size >> 20), @@ -589,7 +593,11 @@ static void __init reserve_crashkernel(void) return; } } - memblock_reserve(crash_base, crash_size); + ret = memblock_reserve(crash_base, crash_size); + if (ret) { + pr_err("%s: Error reserving crashkernel memblock.\n", __func__); + return; + } if (crash_base >= (1ULL << 32) && reserve_crashkernel_low()) { memblock_free(crash_base, crash_size);