public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: mathieu souchaud <rodolphe.souchaud@free.fr>
To: Mathieu Souchaud <mattieu.souchaud@free.fr>,
	tony.luck@intel.com, bp@alien8.de, tglx@linutronix.de,
	mingo@redhat.com, hpa@zytor.com, x86@kernel.org,
	linux-edac@vger.kernel.org, linux-kernel@vger.kernel.org,
	kernel-janitors@vger.kernel.org
Subject: Re: [PATCH v2] x86/mce: Improve mcheck_init_device() error handling
Date: Sat, 03 May 2014 23:25:43 +0200	[thread overview]
Message-ID: <53655ED7.8030404@free.fr> (raw)
In-Reply-To: <1399151031-19905-1-git-send-email-mattieu.souchaud@free.fr>

I took some time to make a light kvm guest and "inject" errors. It seems to work fine (after solving a deadlock issue :) ).

Mathieu S.

Le 03/05/2014 23:03, Mathieu Souchaud a écrit :
> Check return code of every function called by mcheck_init_device().
>
> Signed-off-by: Mathieu Souchaud <mattieu.souchaud@free.fr>
> ---
>   arch/x86/kernel/cpu/mcheck/mce.c |   49 +++++++++++++++++++++++++++++++-------
>   1 file changed, 41 insertions(+), 8 deletions(-)
>
> diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c
> index 68317c8..284cfad 100644
> --- a/arch/x86/kernel/cpu/mcheck/mce.c
> +++ b/arch/x86/kernel/cpu/mcheck/mce.c
> @@ -2437,32 +2437,65 @@ 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 err_out;
> +	}
>   
> -	zalloc_cpumask_var(&mce_device_initialized, GFP_KERNEL);
> +	if (!zalloc_cpumask_var(&mce_device_initialized, GFP_KERNEL)) {
> +		err = -ENOMEM;
> +		goto err_out;
> +	}
>   
>   	mce_init_banks();
>   
>   	err = subsys_system_register(&mce_subsys, NULL);
>   	if (err)
> -		return err;
> +		goto err_out_mem;
>   
>   	cpu_notifier_register_begin();
>   	for_each_online_cpu(i) {
>   		err = mce_device_create(i);
>   		if (err) {
> -			cpu_notifier_register_done();
> -			return err;
> +			goto err_device_create;
>   		}
>   	}
>   
>   	register_syscore_ops(&mce_syscore_ops);
> -	__register_hotcpu_notifier(&mce_cpu_notifier);
> +	err = __register_hotcpu_notifier(&mce_cpu_notifier);
> +	if (err)
> +		goto err_reg_hotcpu;
>   	cpu_notifier_register_done();
>   
>   	/* register character device /dev/mcelog */
> -	misc_register(&mce_chrdev_device);
> +	err = misc_register(&mce_chrdev_device);
> +	if (err)
> +		goto err_register;
> +
> +	return 0;
> +
> +
> +err_register:
> +	cpu_notifier_register_begin();
> +	__unregister_hotcpu_notifier(&mce_cpu_notifier);
> +
> +err_reg_hotcpu:
> +	unregister_syscore_ops(&mce_syscore_ops);
> +
> +err_device_create:
> +	/*
> +	 * mce_device_remove behave properly if mce_device_create was not
> +	 * called on that device.
> +	 */
> +	for_each_possible_cpu(i)
> +		mce_device_remove(i);
> +	cpu_notifier_register_done();
> +
> +err_out_mem:
> +	free_cpumask_var(mce_device_initialized);
> +
> +err_out:
> +	pr_err("Unable to init device /dev/mcelog (rc: %d)\n", err);
>   
>   	return err;
>   }


  reply	other threads:[~2014-05-03 21:26 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-03 21:03 [PATCH v2] x86/mce: Improve mcheck_init_device() error handling Mathieu Souchaud
2014-05-03 21:25 ` mathieu souchaud [this message]
2014-05-05 23:29 ` Luck, Tony
2014-05-06  6:27   ` Ingo Molnar
2014-05-07  9:33     ` mattieu.souchaud
2014-05-22  9:53 ` 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=53655ED7.8030404@free.fr \
    --to=rodolphe.souchaud@free.fr \
    --cc=bp@alien8.de \
    --cc=hpa@zytor.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-edac@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mattieu.souchaud@free.fr \
    --cc=mingo@redhat.com \
    --cc=tglx@linutronix.de \
    --cc=tony.luck@intel.com \
    --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