From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965709AbcKJRre (ORCPT ); Thu, 10 Nov 2016 12:47:34 -0500 Received: from Galois.linutronix.de ([146.0.238.70]:34006 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965528AbcKJRqa (ORCPT ); Thu, 10 Nov 2016 12:46:30 -0500 From: Sebastian Andrzej Siewior To: linux-kernel@vger.kernel.org Cc: tglx@linutronix.de, rt@linutronix.de, Sebastian Andrzej Siewior , Tony Luck , Borislav Petkov , linux-edac@vger.kernel.org, x86@kernel.org Subject: [PATCH 3/7] x86/mcheck: Be prepared for a rollback back to the ONLINE state Date: Thu, 10 Nov 2016 18:44:43 +0100 Message-Id: <20161110174447.11848-4-bigeasy@linutronix.de> X-Mailer: git-send-email 2.10.2 In-Reply-To: <20161110174447.11848-1-bigeasy@linutronix.de> References: <20161110091809.vxyf3yiuxtjy3vqv@pd.tnic> <20161110174447.11848-1-bigeasy@linutronix.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Cc: Tony Luck Cc: Borislav Petkov Cc: linux-edac@vger.kernel.org Cc: x86@kernel.org Signed-off-by: Sebastian Andrzej Siewior Signed-off-by: Thomas Gleixner --- arch/x86/kernel/cpu/mcheck/mce.c | 4 ++++ arch/x86/kernel/cpu/mcheck/mce_amd.c | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/= mce.c index a7fdf453d895..e9ffd6d9e32d 100644 --- a/arch/x86/kernel/cpu/mcheck/mce.c +++ b/arch/x86/kernel/cpu/mcheck/mce.c @@ -2409,6 +2409,10 @@ static int mce_device_create(unsigned int cpu) if (!mce_available(&boot_cpu_data)) return -EIO; =20 + dev =3D per_cpu(mce_device, cpu); + if (dev) + return 0; + dev =3D kzalloc(sizeof *dev, GFP_KERNEL); if (!dev) return -ENOMEM; diff --git a/arch/x86/kernel/cpu/mcheck/mce_amd.c b/arch/x86/kernel/cpu/mch= eck/mce_amd.c index 55cd018bc1ae..e93580c82ef0 100644 --- a/arch/x86/kernel/cpu/mcheck/mce_amd.c +++ b/arch/x86/kernel/cpu/mcheck/mce_amd.c @@ -1097,6 +1097,10 @@ static int threshold_create_device(unsigned int cpu) struct threshold_bank **bp; int err =3D 0; =20 + bp =3D per_cpu(threshold_banks, cpu); + if (bp) + return 0; + bp =3D kzalloc(sizeof(struct threshold_bank *) * mca_cfg.banks, GFP_KERNEL); if (!bp) --=20 2.10.2