提交 7f34b935 编写于 作者: S Sebastian Andrzej Siewior 提交者: Thomas Gleixner

x86/mcheck: Be prepared for a rollback back to the ONLINE state

If we try a CPU down and fail in the middle then we roll back to the
online state. This means we would perform CPU_ONLINE / mce_device_create()
without invoking CPU_DEAD / mce_device_remove() for the cleanup of what was
allocated in CPU_ONLINE.

Be prepared for this and don't allocate the struct if we have it
already.
Signed-off-by: NSebastian Andrzej Siewior <bigeasy@linutronix.de>
Acked-by: NBorislav Petkov <bp@alien8.de>
Cc: Tony Luck <tony.luck@intel.com>
Cc: rt@linutronix.de
Cc: linux-edac@vger.kernel.org
Link: http://lkml.kernel.org/r/20161110174447.11848-4-bigeasy@linutronix.deSigned-off-by: NThomas Gleixner <tglx@linutronix.de>
上级 ec553abb
...@@ -2409,6 +2409,10 @@ static int mce_device_create(unsigned int cpu) ...@@ -2409,6 +2409,10 @@ static int mce_device_create(unsigned int cpu)
if (!mce_available(&boot_cpu_data)) if (!mce_available(&boot_cpu_data))
return -EIO; return -EIO;
dev = per_cpu(mce_device, cpu);
if (dev)
return 0;
dev = kzalloc(sizeof *dev, GFP_KERNEL); dev = kzalloc(sizeof *dev, GFP_KERNEL);
if (!dev) if (!dev)
return -ENOMEM; return -ENOMEM;
......
...@@ -1097,6 +1097,10 @@ static int threshold_create_device(unsigned int cpu) ...@@ -1097,6 +1097,10 @@ static int threshold_create_device(unsigned int cpu)
struct threshold_bank **bp; struct threshold_bank **bp;
int err = 0; int err = 0;
bp = per_cpu(threshold_banks, cpu);
if (bp)
return 0;
bp = kzalloc(sizeof(struct threshold_bank *) * mca_cfg.banks, bp = kzalloc(sizeof(struct threshold_bank *) * mca_cfg.banks,
GFP_KERNEL); GFP_KERNEL);
if (!bp) if (!bp)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册