Skip to content

Commit

Permalink
xen/mce: fix up xen_late_init_mcelog() error handling
Browse files Browse the repository at this point in the history
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>
Signed-off-by: David Vrabel <david.vrabel@citrix.com>
  • Loading branch information
Dan Carpenter authored and David Vrabel committed Mar 16, 2015
1 parent 4e8c0c8 commit ebfe79a
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions drivers/xen/mcelog.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

0 comments on commit ebfe79a

Please sign in to comment.