linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: tip-bot for Borislav Petkov <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: chaowang@redhat.com, jgross@suse.com, msalter@redhat.com,
	jroedel@suse.de, torvalds@linux-foundation.org, hpa@zytor.com,
	akpm@linux-foundation.org, mingo@kernel.org,
	peterz@infradead.org, bp@suse.de, tglx@linutronix.de,
	jkosina@suse.cz, luto@amacapital.net,
	linux-kernel@vger.kernel.org, dyoung@redhat.com
Subject: [tip:ras/core] x86/setup/crash: Check memblock_reserve() retval
Date: Wed, 21 Oct 2015 03:05:48 -0700	[thread overview]
Message-ID: <tip-6f3760570e26eefc214e641b6daeddb7106240bb@git.kernel.org> (raw)
In-Reply-To: <1445246268-26285-7-git-send-email-bp@alien8.de>

Commit-ID:  6f3760570e26eefc214e641b6daeddb7106240bb
Gitweb:     http://git.kernel.org/tip/6f3760570e26eefc214e641b6daeddb7106240bb
Author:     Borislav Petkov <bp@suse.de>
AuthorDate: Mon, 19 Oct 2015 11:17:46 +0200
Committer:  Ingo Molnar <mingo@kernel.org>
CommitDate: Wed, 21 Oct 2015 11:10:56 +0200

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 <bp@suse.de>
Reviewed-by: Dave Young <dyoung@redhat.com>
Reviewed-by: Joerg Roedel <jroedel@suse.de>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Andy Lutomirski <luto@amacapital.net>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Jiri Kosina <jkosina@suse.cz>
Cc: Juergen Gross <jgross@suse.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Mark Salter <msalter@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: WANG Chao <chaowang@redhat.com>
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 <mingo@kernel.org>
---
 arch/x86/kernel/setup.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
index d478871..3f75297 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);

  reply	other threads:[~2015-10-21 10:06 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-19  9:17 [PATCH 0/8] tip-queue 2015-10-19 Borislav Petkov
2015-10-19  9:17 ` [PATCH 1/8] x86/setup: Do not reserve crashkernel high memory if low reservation failed Borislav Petkov
2015-10-21 10:04   ` [tip:ras/core] " tip-bot for Baoquan He
2015-10-19  9:17 ` [PATCH 2/8] x86/amd_nb, EDAC: Rename amd_get_node_id() Borislav Petkov
2015-10-21 10:04   ` [tip:ras/core] " tip-bot for Aravind Gopalakrishnan
2015-10-19  9:17 ` [PATCH 3/8] x86/setup: Cleanup crashkernel reservation functions Borislav Petkov
2015-10-21 10:04   ` [tip:ras/core] " tip-bot for Borislav Petkov
2015-10-19  9:17 ` [PATCH 4/8] x86/setup/crash: Remove alignment variable Borislav Petkov
2015-10-21 10:05   ` [tip:ras/core] " tip-bot for Borislav Petkov
2015-10-19  9:17 ` [PATCH 5/8] x86/setup/crash: Cleanup some more Borislav Petkov
2015-10-21 10:05   ` [tip:ras/core] " tip-bot for Borislav Petkov
2015-10-19  9:17 ` [PATCH 6/8] x86/setup/crash: Check memblock_reserve() retval Borislav Petkov
2015-10-21 10:05   ` tip-bot for Borislav Petkov [this message]
2015-10-19  9:17 ` [PATCH 7/8] kexec/crash: Say which char is the unrecognized Borislav Petkov
2015-10-21 10:06   ` [tip:ras/core] " tip-bot for Borislav Petkov
2015-10-19  9:17 ` [PATCH 8/8] x86/mce: Fix thermal throttling reporting after kexec Borislav Petkov
2015-10-21 10:06   ` [tip:ras/core] " tip-bot for Andi Kleen

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=tip-6f3760570e26eefc214e641b6daeddb7106240bb@git.kernel.org \
    --to=tipbot@zytor.com \
    --cc=akpm@linux-foundation.org \
    --cc=bp@suse.de \
    --cc=chaowang@redhat.com \
    --cc=dyoung@redhat.com \
    --cc=hpa@zytor.com \
    --cc=jgross@suse.com \
    --cc=jkosina@suse.cz \
    --cc=jroedel@suse.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=luto@amacapital.net \
    --cc=mingo@kernel.org \
    --cc=msalter@redhat.com \
    --cc=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    --cc=torvalds@linux-foundation.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).