[PATCH] x86, amd, mce: Prevent potential cpu-online oops

From: Daniel J Blueman
Date: Thu Apr 04 2013 - 11:54:22 EST


On platforms where all Northbridges may not be visible (due to routing, eg on
NumaConnect systems), prevent oopsing due to stale pointer access when
offlining cores.

Signed-off-by: Steffen Persvold <sp@xxxxxxxxxxxxx>
Signed-off-by: Daniel J Blueman <daniel@xxxxxxxxxxxxxxxxxx>

---
arch/x86/kernel/cpu/mcheck/mce_amd.c | 11 ++++++-----
1 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/arch/x86/kernel/cpu/mcheck/mce_amd.c b/arch/x86/kernel/cpu/mcheck/mce_amd.c
index 1ac581f..53a58c2 100644
--- a/arch/x86/kernel/cpu/mcheck/mce_amd.c
+++ b/arch/x86/kernel/cpu/mcheck/mce_amd.c
@@ -578,8 +578,11 @@ static __cpuinit int threshold_create_bank(unsigned int cpu, unsigned int bank)
if (shared_bank[bank]) {
nb = node_to_amd_nb(amd_get_nb_id(cpu));

+ if (WARN_ON_ONCE(!nb))
+ goto out;
+
/* threshold descriptor already initialized on this node? */
- if (nb && nb->bank4) {
+ if (nb->bank4) {
/* yes, use it */
b = nb->bank4;
err = kobject_add(b->kobj, &dev->kobj, name);
@@ -613,10 +616,8 @@ static __cpuinit int threshold_create_bank(unsigned int cpu, unsigned int bank)
atomic_set(&b->cpus, 1);

/* nb is already initialized, see above */
- if (nb) {
- WARN_ON(nb->bank4);
- nb->bank4 = b;
- }
+ WARN_ON(nb->bank4);
+ nb->bank4 = b;
}

err = allocate_threshold_blocks(cpu, bank, 0,
--
1.7.4.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/