From: luanshi <zhangliguang@linux.alibaba.com>
To: Tony Luck <tony.luck@intel.com>, Borislav Petkov <bp@alien8.de>
Cc: linux-edac@vger.kernel.org
Subject: [PATCH] x86/mce: Fix memleak in mce_banks
Date: Thu, 6 Jun 2019 15:09:27 +0800 [thread overview]
Message-ID: <1559804967-46320-1-git-send-email-zhangliguang@linux.alibaba.com> (raw)
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
next reply other threads:[~2019-06-06 7:09 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-06 7:09 luanshi [this message]
2019-06-06 7:50 ` [PATCH] x86/mce: Fix memleak in mce_banks Borislav Petkov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1559804967-46320-1-git-send-email-zhangliguang@linux.alibaba.com \
--to=zhangliguang@linux.alibaba.com \
--cc=bp@alien8.de \
--cc=linux-edac@vger.kernel.org \
--cc=tony.luck@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).