From: Dan Carpenter <error27@gmail.com>
To: kernel-janitors@vger.kernel.org
Subject: Re: [PATCH] x86: mce: Potential memory leaks when initializing
Date: Fri, 04 Mar 2011 10:51:56 +0000 [thread overview]
Message-ID: <20110304092000.GA3416@bicker> (raw)
In-Reply-To: <1299179552-31563-1-git-send-email-johan.wessfeldt@gmail.com>
On Thu, Mar 03, 2011 at 08:12:32PM +0100, Johan Wessfeldt wrote:
> This patch makes sure cleanup is done properly when mcheck fails
> initializing any of its resources.
>
> Note!
> It should be safe to call mce_remove_device on ANY of the cpus as
> mce_remove_device checks if corresponding cpu was initialized
> before removing its resources.
>
> Please review.
>
Looks good. Maybe a couple style quibles. Also this will need to be
resent to the proper people.
./scripts/get_maintainer.pl -f arch/x86/kernel/cpu/mcheck/mce.c
The important thing is send it to x86@kernel.org, but really if you're
messing with bootup code then I would CC lkml as well so it gets
more review. The code seems straight forward enough but review never
hurts.
> Signed-off-by: Johan Wessfeldt <johan.wessfeldt@gmail.com>
> ---
> arch/x86/kernel/cpu/mcheck/mce.c | 26 ++++++++++++++++++++------
> 1 files changed, 20 insertions(+), 6 deletions(-)
>
> diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c
> index d916183..a9e3820 100644
> --- a/arch/x86/kernel/cpu/mcheck/mce.c
> +++ b/arch/x86/kernel/cpu/mcheck/mce.c
> @@ -2122,8 +2122,10 @@ static __init int mcheck_init_device(void)
> int err;
> int i = 0;
>
> - if (!mce_available(&boot_cpu_data))
> - return -EIO;
> + if (!mce_available(&boot_cpu_data)) {
> + err = -EIO;
> + goto out;
Return directly here. A person reading this will probably think that
there is an unlock or something at the end of the function. But really
it's there for no reason. Don't do that.
> + }
>
> zalloc_cpumask_var(&mce_dev_initialized, GFP_KERNEL);
>
> @@ -2131,20 +2133,32 @@ static __init int mcheck_init_device(void)
>
> err = sysdev_class_register(&mce_sysclass);
> if (err)
> - return err;
> + goto out;
And here.
>
> 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:
> + i = 0;
^^^^^^
Remove this as well.
> + for_each_online_cpu(i)
> + mce_remove_device(i);
> +
> + sysdev_class_unregister(&mce_sysclass);
> +out:
> return err;
> }
regards,
dan carpenter
prev parent reply other threads:[~2011-03-04 10:51 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-03-03 19:12 [PATCH] x86: mce: Potential memory leaks when initializing mcheck devices Johan Wessfeldt
2011-03-04 10:51 ` Dan Carpenter [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=20110304092000.GA3416@bicker \
--to=error27@gmail.com \
--cc=kernel-janitors@vger.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