From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752085AbcGAIaA (ORCPT ); Fri, 1 Jul 2016 04:30:00 -0400 Received: from terminus.zytor.com ([198.137.202.10]:33728 "EHLO mail.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751036AbcGAI35 (ORCPT ); Fri, 1 Jul 2016 04:29:57 -0400 Date: Fri, 1 Jul 2016 00:40:16 -0700 From: tip-bot for Borislav Petkov Message-ID: 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 Reply-To: hpa@zytor.com, mingo@kernel.org, tglx@linutronix.de, torvalds@linux-foundation.org, stable@vger.kernel.org, peterz@infradead.org, linux-kernel@vger.kernel.org, tonyb@cybernetics.com, bp@suse.de In-Reply-To: <1466097230-5333-2-git-send-email-bp@alien8.de> References: <1466097230-5333-2-git-send-email-bp@alien8.de> To: linux-tip-commits@vger.kernel.org Subject: [tip:x86/urgent] x86/amd_nb: Fix boot crash on non-AMD systems Git-Commit-ID: 1ead852dd88779eda12cb09cc894a03d9abfe1ec X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: 1ead852dd88779eda12cb09cc894a03d9abfe1ec Gitweb: http://git.kernel.org/tip/1ead852dd88779eda12cb09cc894a03d9abfe1ec Author: Borislav Petkov AuthorDate: Thu, 16 Jun 2016 19:13:49 +0200 Committer: Ingo Molnar 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 Signed-off-by: Borislav Petkov Cc: Cc: Linus Torvalds Cc: Peter Zijlstra Cc: Thomas Gleixner 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 --- 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)