aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Carpenter <dan.carpenter@oracle.com>2015-03-05 06:24:17 -0500
committerDavid Vrabel <david.vrabel@citrix.com>2015-03-16 10:49:15 -0400
commitebfe79a7c85c171def09ff86f6fdea254a51d6c9 (patch)
tree7866d06e9560bee83343c2b08fd20fe47d87bfdb
parent4e8c0c8c4bf3a5b5c98046e146ab3884bf7a7d0e (diff)
xen/mce: fix up xen_late_init_mcelog() error handling
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>
-rw-r--r--drivers/xen/mcelog.c25
1 files changed, 18 insertions, 7 deletions
diff --git a/drivers/xen/mcelog.c b/drivers/xen/mcelog.c
index 6ab6a79c38a5..a493c7315e94 100644
--- a/drivers/xen/mcelog.c
+++ b/drivers/xen/mcelog.c
@@ -393,14 +393,25 @@ static int bind_virq_for_mce(void)
393 393
394static int __init xen_late_init_mcelog(void) 394static int __init xen_late_init_mcelog(void)
395{ 395{
396 int ret;
397
396 /* Only DOM0 is responsible for MCE logging */ 398 /* Only DOM0 is responsible for MCE logging */
397 if (xen_initial_domain()) { 399 if (!xen_initial_domain())
398 /* register character device /dev/mcelog for xen mcelog */ 400 return -ENODEV;
399 if (misc_register(&xen_mce_chrdev_device)) 401
400 return -ENODEV; 402 /* register character device /dev/mcelog for xen mcelog */
401 return bind_virq_for_mce(); 403 ret = misc_register(&xen_mce_chrdev_device);
402 } 404 if (ret)
405 return ret;
406
407 ret = bind_virq_for_mce();
408 if (ret)
409 goto deregister;
403 410
404 return -ENODEV; 411 return 0;
412
413deregister:
414 misc_deregister(&xen_mce_chrdev_device);
415 return ret;
405} 416}
406device_initcall(xen_late_init_mcelog); 417device_initcall(xen_late_init_mcelog);