public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: tip-bot for Borislav Petkov <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: bp@suse.de, tonyb@cybernetics.com, linux-kernel@vger.kernel.org,
	peterz@infradead.org, stable@vger.kernel.org,
	torvalds@linux-foundation.org, mingo@kernel.org,
	tglx@linutronix.de, hpa@zytor.com
Subject: [tip:x86/urgent] x86/amd_nb: Fix boot crash on non-AMD systems
Date: Fri, 1 Jul 2016 00:40:16 -0700	[thread overview]
Message-ID: <tip-1ead852dd88779eda12cb09cc894a03d9abfe1ec@git.kernel.org> (raw)
In-Reply-To: <1466097230-5333-2-git-send-email-bp@alien8.de>

Commit-ID:  1ead852dd88779eda12cb09cc894a03d9abfe1ec
Gitweb:     http://git.kernel.org/tip/1ead852dd88779eda12cb09cc894a03d9abfe1ec
Author:     Borislav Petkov <bp@suse.de>
AuthorDate: Thu, 16 Jun 2016 19:13:49 +0200
Committer:  Ingo Molnar <mingo@kernel.org>
CommitDate: Fri, 1 Jul 2016 09:35:35 +0200

x86/amd_nb: Fix boot crash on non-AMD systems

Fix boot crash that triggers if this driver is built into a kernel and
run on non-AMD systems.

AMD northbridges users call amd_cache_northbridges() and it returns
a negative value to signal that we weren't able to cache/detect any
northbridges on the system.

At least, it should do so as all its callers expect it to do so. But it
does return a negative value only when kmalloc() fails.

Fix it to return -ENODEV if there are no NBs cached as otherwise, amd_nb
users like amd64_edac, for example, which relies on it to know whether
it should load or not, gets loaded on systems like Intel Xeons where it
shouldn't.

Reported-and-tested-by: Tony Battersby <tonyb@cybernetics.com>
Signed-off-by: Borislav Petkov <bp@suse.de>
Cc: <stable@vger.kernel.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/1466097230-5333-2-git-send-email-bp@alien8.de
Link: https://lkml.kernel.org/r/5761BEB0.9000807@cybernetics.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 arch/x86/kernel/amd_nb.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kernel/amd_nb.c b/arch/x86/kernel/amd_nb.c
index a147e67..e991d5c 100644
--- a/arch/x86/kernel/amd_nb.c
+++ b/arch/x86/kernel/amd_nb.c
@@ -71,8 +71,8 @@ int amd_cache_northbridges(void)
 	while ((misc = next_northbridge(misc, amd_nb_misc_ids)) != NULL)
 		i++;
 
-	if (i == 0)
-		return 0;
+	if (!i)
+		return -ENODEV;
 
 	nb = kzalloc(i * sizeof(struct amd_northbridge), GFP_KERNEL);
 	if (!nb)

  reply	other threads:[~2016-07-01  8:30 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-16 17:13 [PATCH 0/2] x86/amd_nb: Two fixes Borislav Petkov
2016-06-16 17:13 ` [PATCH 1/2] x86/amd_nb: Return negative value when no northbridges Borislav Petkov
2016-07-01  7:40   ` tip-bot for Borislav Petkov [this message]
2016-06-16 17:13 ` [PATCH 2/2] x86/amd_nb: Cleanup init path Borislav Petkov
2016-07-01  7:46   ` [tip:x86/cpu] x86/amd_nb: Clean up " tip-bot for Borislav Petkov

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-1ead852dd88779eda12cb09cc894a03d9abfe1ec@git.kernel.org \
    --to=tipbot@zytor.com \
    --cc=bp@suse.de \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=peterz@infradead.org \
    --cc=stable@vger.kernel.org \
    --cc=tglx@linutronix.de \
    --cc=tonyb@cybernetics.com \
    --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