Linux-EDAC Archive on lore.kernel.org
 help / color / 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	[flat|nested] 2+ messages in thread

* Re: [PATCH] x86/mce: Fix memleak in mce_banks
  2019-06-06  7:09 [PATCH] x86/mce: Fix memleak in mce_banks luanshi
@ 2019-06-06  7:50 ` Borislav Petkov
  0 siblings, 0 replies; 2+ messages in thread
From: Borislav Petkov @ 2019-06-06  7:50 UTC (permalink / raw)
  To: luanshi; +Cc: Tony Luck, linux-edac

On Thu, Jun 06, 2019 at 03:09:27PM +0800, luanshi wrote:
> 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.

Maybe my reply from last night wasn't clear so lemme repeat it again:
this patch is not needed because we're removing the kcalloc call there
and the banks will be allocated statically in the future.

-- 
Regards/Gruss,
    Boris.

Good mailing practices for 400: avoid top-posting and trim the reply.

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

end of thread, back to index

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

Linux-EDAC Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-edac/0 linux-edac/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-edac linux-edac/ https://lore.kernel.org/linux-edac \
		linux-edac@vger.kernel.org linux-edac@archiver.kernel.org
	public-inbox-index linux-edac


Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-edac


AGPL code for this site: git clone https://public-inbox.org/ public-inbox