Commit 583e3ee1 authored by Borislav Petkov's avatar Borislav Petkov Committed by Willy Tarreau

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

commit 1ead852d upstream.

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: default avatarTony Battersby <tonyb@cybernetics.com>
Signed-off-by: default avatarBorislav 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.comSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
Signed-off-by: default avatarWilly Tarreau <w@1wt.eu>
parent b92e992e
...@@ -67,8 +67,8 @@ int amd_cache_northbridges(void) ...@@ -67,8 +67,8 @@ int amd_cache_northbridges(void)
while ((misc = next_northbridge(misc, amd_nb_misc_ids)) != NULL) while ((misc = next_northbridge(misc, amd_nb_misc_ids)) != NULL)
i++; i++;
if (i == 0) if (!i)
return 0; return -ENODEV;
nb = kzalloc(i * sizeof(struct amd_northbridge), GFP_KERNEL); nb = kzalloc(i * sizeof(struct amd_northbridge), GFP_KERNEL);
if (!nb) if (!nb)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment