From: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
To: kernel-janitors@vger.kernel.org
Subject: Re: [patch] xen/mce: fix up xen_late_init_mcelog() error handling
Date: Fri, 06 Mar 2015 18:30:05 +0000 [thread overview]
Message-ID: <20150306183005.GB13360@l.oracle.com> (raw)
In-Reply-To: <20150305112417.GA13378@mwanda>
On Thu, Mar 05, 2015 at 02:24:17PM +0300, Dan Carpenter wrote:
> Static checkers complain about the missing call to misc_deregister() if
> bind_virq_for_mce() fails.
>
> Also I reversed the tests so that we do error handling instead of
> success handling. That way we just have a series of function calls
> instead of the more complicated nested if statements in the original
> code. Let's preserve the error codes as well.
>
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
David, you want me to stash in devel for 4.1?
>
> diff --git a/drivers/xen/mcelog.c b/drivers/xen/mcelog.c
> index 6ab6a79..a493c7315 100644
> --- a/drivers/xen/mcelog.c
> +++ b/drivers/xen/mcelog.c
> @@ -393,14 +393,25 @@ static int bind_virq_for_mce(void)
>
> static int __init xen_late_init_mcelog(void)
> {
> + int ret;
> +
> /* Only DOM0 is responsible for MCE logging */
> - if (xen_initial_domain()) {
> - /* register character device /dev/mcelog for xen mcelog */
> - if (misc_register(&xen_mce_chrdev_device))
> - return -ENODEV;
> - return bind_virq_for_mce();
> - }
> + if (!xen_initial_domain())
> + return -ENODEV;
> +
> + /* register character device /dev/mcelog for xen mcelog */
> + ret = misc_register(&xen_mce_chrdev_device);
> + if (ret)
> + return ret;
> +
> + ret = bind_virq_for_mce();
> + if (ret)
> + goto deregister;
>
> - return -ENODEV;
> + return 0;
> +
> +deregister:
> + misc_deregister(&xen_mce_chrdev_device);
> + return ret;
> }
> device_initcall(xen_late_init_mcelog);
prev parent reply other threads:[~2015-03-06 18:30 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-05 11:24 [patch] xen/mce: fix up xen_late_init_mcelog() error handling Dan Carpenter
2015-03-06 18:30 ` Konrad Rzeszutek Wilk [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=20150306183005.GB13360@l.oracle.com \
--to=konrad.wilk@oracle.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