From: Johan Wessfeldt <johan.wessfeldt@gmail.com>
To: unlisted-recipients:; (no To-header on input)
Cc: x86@kernel.org, tglx@linutronix.de, linux-kernel@vger.kernel.org,
Johan Wessfeldt <johan.wessfeldt@gmail.com>
Subject: [PATCH V2] x86: mce: Potential memory leaks when initializing mcheck devices
Date: Mon, 7 Mar 2011 11:36:23 +0100 [thread overview]
Message-ID: <1299494183-7380-1-git-send-email-johan.wessfeldt@gmail.com> (raw)
In-Reply-To: <AANLkTikMY+7ApHCXY_jjue9RRCE-ORKrj4pAyy5H0W8_@mail.gmail.com>
This patch makes sure cleanup is done properly when mcheck fails
initializing any of its resources.
Signed-off-by: Johan Wessfeldt <johan.wessfeldt@gmail.com>
---
v2: call free_cpumask_var() if sysdev_class_register() fails
arch/x86/kernel/cpu/mcheck/mce.c | 20 ++++++++++++++++----
1 files changed, 16 insertions(+), 4 deletions(-)
diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c
index d916183..3cbd5a0 100644
--- a/arch/x86/kernel/cpu/mcheck/mce.c
+++ b/arch/x86/kernel/cpu/mcheck/mce.c
@@ -2131,20 +2131,32 @@ static __init int mcheck_init_device(void)
err = sysdev_class_register(&mce_sysclass);
if (err)
- return err;
+ goto out_free;
for_each_online_cpu(i) {
err = mce_create_device(i);
if (err)
- return err;
+ goto out_unreg;
}
register_hotcpu_notifier(&mce_cpu_notifier);
- misc_register(&mce_log_device);
+ err = misc_register(&mce_log_device);
+ if (err)
+ goto out_unreg_hotcpu;
+ return 0;
+
+out_unreg_hotcpu:
+ unregister_hotcpu_notifier(&mce_cpu_notifier);
+out_unreg:
+ for_each_online_cpu(i)
+ mce_remove_device(i);
+
+ sysdev_class_unregister(&mce_sysclass);
+out_free:
+ free_cpumask_var(mce_dev_initialized);
return err;
}
-
device_initcall(mcheck_init_device);
/*
--
1.7.2.3
prev parent reply other threads:[~2011-03-07 10:37 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-03-04 18:31 [PATCH] " Johan Wessfeldt
2011-03-07 6:56 ` Johan Wessfeldt
2011-03-07 10:36 ` Johan Wessfeldt [this message]
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=1299494183-7380-1-git-send-email-johan.wessfeldt@gmail.com \
--to=johan.wessfeldt@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=tglx@linutronix.de \
--cc=x86@kernel.org \
/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
all inboxes | Powered by JetHome®