From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935017AbcKPIkq (ORCPT ); Wed, 16 Nov 2016 03:40:46 -0500 Received: from terminus.zytor.com ([198.137.202.10]:58058 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932985AbcKPIkp (ORCPT ); Wed, 16 Nov 2016 03:40:45 -0500 Date: Wed, 16 Nov 2016 00:40:20 -0800 From: tip-bot for Sebastian Andrzej Siewior Message-ID: Cc: linux-kernel@vger.kernel.org, tony.luck@intel.com, mingo@kernel.org, tglx@linutronix.de, hpa@zytor.com, bigeasy@linutronix.de, bp@alien8.de Reply-To: bp@alien8.de, hpa@zytor.com, bigeasy@linutronix.de, tglx@linutronix.de, tony.luck@intel.com, mingo@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20161110174447.11848-3-bigeasy@linutronix.de> References: <20161110174447.11848-3-bigeasy@linutronix.de> To: linux-tip-commits@vger.kernel.org Subject: [tip:smp/hotplug] x86/mcheck: Explicit cleanup on failure in mce_amd Git-Commit-ID: ec553abb318d75b1eafd275c71125569fa13b33b 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: ec553abb318d75b1eafd275c71125569fa13b33b Gitweb: http://git.kernel.org/tip/ec553abb318d75b1eafd275c71125569fa13b33b Author: Sebastian Andrzej Siewior AuthorDate: Thu, 10 Nov 2016 18:44:42 +0100 Committer: Thomas Gleixner CommitDate: Wed, 16 Nov 2016 09:34:17 +0100 x86/mcheck: Explicit cleanup on failure in mce_amd If the ONLINE callback fails, the driver does not any clean up right away instead it waits to get to the DEAD stage to do it. Yes, it waits. Since we don't pass the error code back to the caller, no one knows. Do the clean up right away so it does not look like a leak. Signed-off-by: Sebastian Andrzej Siewior Acked-by: Borislav Petkov Cc: Tony Luck Cc: rt@linutronix.de Cc: linux-edac@vger.kernel.org Link: http://lkml.kernel.org/r/20161110174447.11848-3-bigeasy@linutronix.de Signed-off-by: Thomas Gleixner --- arch/x86/kernel/cpu/mcheck/mce_amd.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/arch/x86/kernel/cpu/mcheck/mce_amd.c b/arch/x86/kernel/cpu/mcheck/mce_amd.c index 75a3e3e..55cd018 100644 --- a/arch/x86/kernel/cpu/mcheck/mce_amd.c +++ b/arch/x86/kernel/cpu/mcheck/mce_amd.c @@ -1087,6 +1087,7 @@ static void threshold_remove_device(unsigned int cpu) threshold_remove_bank(cpu, bank); } kfree(per_cpu(threshold_banks, cpu)); + per_cpu(threshold_banks, cpu) = NULL; } /* create dir/files for all valid threshold banks */ @@ -1108,9 +1109,11 @@ static int threshold_create_device(unsigned int cpu) continue; err = threshold_create_bank(cpu, bank); if (err) - return err; + goto err; } - + return err; +err: + threshold_remove_device(cpu); return err; }