linux-edac.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] x86/mce: Fix memleak in mce_banks
@ 2019-06-06  7:09 luanshi
  2019-06-06  7:50 ` Borislav Petkov
  0 siblings, 1 reply; 2+ messages in thread
From: luanshi @ 2019-06-06  7:09 UTC (permalink / raw)
  To: Tony Luck, Borislav Petkov; +Cc: linux-edac

From: zhangliguang <zhangliguang@linux.alibaba.com>

The mce_banks is leaked in the error out cases during
__mcheck_cpu_apply_quirks and mce_gen_pool_init. This patch fixes it.

Signed-off-by: zhangliguang <zhangliguang@linux.alibaba.com>
---
 arch/x86/kernel/cpu/mce/core.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/arch/x86/kernel/cpu/mce/core.c b/arch/x86/kernel/cpu/mce/core.c
index 282916f..cee6d4b 100644
--- a/arch/x86/kernel/cpu/mce/core.c
+++ b/arch/x86/kernel/cpu/mce/core.c
@@ -1816,11 +1816,14 @@ void mcheck_cpu_init(struct cpuinfo_x86 *c)
 		return;
 
 	if (__mcheck_cpu_cap_init() < 0 || __mcheck_cpu_apply_quirks(c) < 0) {
+		if (mce_banks)
+			kfree(mce_banks);
 		mca_cfg.disabled = 1;
 		return;
 	}
 
 	if (mce_gen_pool_init()) {
+		kfree(mce_banks);
 		mca_cfg.disabled = 1;
 		pr_emerg("Couldn't allocate MCE records pool!\n");
 		return;
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-06-06  7:50 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-06  7:09 [PATCH] x86/mce: Fix memleak in mce_banks luanshi
2019-06-06  7:50 ` Borislav Petkov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).