[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <AANLkTi=bPk+AjP_JLA2p0+FB_beekBt1fikVx0KA87Fh@mail.gmail.com>
Date: Fri, 4 Mar 2011 22:38:35 +0100
From: Johan Wessfeldt <johan.wessfeldt@...il.com>
To: "J.P. Lacerda" <jp.lacerda@...ethink.co.uk>
Cc: akpm@...ux-foundation.org, tglx@...utronix.de, mingo@...hat.com,
x86@...nel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH 1/1] x86: Fix mcheck_init_device() to handle
misc_register() correctly
On Fri, Mar 4, 2011 at 2:29 PM, J.P. Lacerda <jp.lacerda@...ethink.co.uk> wrote:
> The return value for misc_register() was not being taken into account.
> Furthermore, if misc_register() fails, we must rollback any changes made by
> mcheck_init_device()
>
> Signed-off-by: J.P. Lacerda <jp.lacerda@...ethink.co.uk>
> ---
> arch/x86/kernel/cpu/mcheck/mce.c | 13 ++++++++++++-
> 1 files changed, 12 insertions(+), 1 deletions(-)
>
> diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c
> index d916183..20c2c44 100644
> --- a/arch/x86/kernel/cpu/mcheck/mce.c
> +++ b/arch/x86/kernel/cpu/mcheck/mce.c
> @@ -2140,7 +2140,18 @@ static __init int mcheck_init_device(void)
> }
>
> register_hotcpu_notifier(&mce_cpu_notifier);
> - misc_register(&mce_log_device);
> + err = misc_register(&mce_log_device);
> +
> + if (err) {
> + unregister_hotcpu_notifier(&mce_cpu_notifier);
> +
> + for_each_online_cpu(i) {
> + mce_remove_device(i);
> + }
> +
> + sysdev_class_unregister(&mce_sysclass);
> + free_cpumask_var(mce_dev_initialized);
> + }
>
> return err;
> }
> --
> 1.7.1
>
>
I want to thank J.P. Lacerda for pointing out an additional leak that I
missed in my first version. ie. calling free_cpumask_var(mce_dev_initialized).
Regards.
// Johan W.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists