All of lore.kernel.org
 help / color / mirror / Atom feed
* [patch] xen/mce: fix up xen_late_init_mcelog() error handling
@ 2015-03-05 11:24 Dan Carpenter
  0 siblings, 0 replies; 5+ messages in thread
From: Dan Carpenter @ 2015-03-05 11:24 UTC (permalink / raw)
  To: Konrad Rzeszutek Wilk
  Cc: xen-devel, Boris Ostrovsky, kernel-janitors, David Vrabel

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>

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);

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [patch] xen/mce: fix up xen_late_init_mcelog() error handling
  2015-03-05 11:24 Dan Carpenter
  2015-03-06 18:30 ` Konrad Rzeszutek Wilk
  2015-03-06 18:30 ` Konrad Rzeszutek Wilk
@ 2015-03-16 14:47 ` David Vrabel
  2 siblings, 0 replies; 5+ messages in thread
From: David Vrabel @ 2015-03-16 14:47 UTC (permalink / raw)
  To: Dan Carpenter, Konrad Rzeszutek Wilk
  Cc: xen-devel, Boris Ostrovsky, kernel-janitors, David Vrabel

On 05/03/15 11:24, 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.

Applied to devel/for-linus-4.1, thanks.

David

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [patch] xen/mce: fix up xen_late_init_mcelog() error handling
  2015-03-05 11:24 Dan Carpenter
@ 2015-03-06 18:30 ` Konrad Rzeszutek Wilk
  2015-03-06 18:30 ` Konrad Rzeszutek Wilk
  2015-03-16 14:47 ` David Vrabel
  2 siblings, 0 replies; 5+ messages in thread
From: Konrad Rzeszutek Wilk @ 2015-03-06 18:30 UTC (permalink / raw)
  To: kernel-janitors

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);

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [patch] xen/mce: fix up xen_late_init_mcelog() error handling
  2015-03-05 11:24 Dan Carpenter
  2015-03-06 18:30 ` Konrad Rzeszutek Wilk
@ 2015-03-06 18:30 ` Konrad Rzeszutek Wilk
  2015-03-16 14:47 ` David Vrabel
  2 siblings, 0 replies; 5+ messages in thread
From: Konrad Rzeszutek Wilk @ 2015-03-06 18:30 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: xen-devel, Boris Ostrovsky, kernel-janitors, David Vrabel

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);

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [patch] xen/mce: fix up xen_late_init_mcelog() error handling
@ 2015-03-05 11:24 Dan Carpenter
  2015-03-06 18:30 ` Konrad Rzeszutek Wilk
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Dan Carpenter @ 2015-03-05 11:24 UTC (permalink / raw)
  To: kernel-janitors

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>

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);

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2015-03-16 14:47 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-05 11:24 [patch] xen/mce: fix up xen_late_init_mcelog() error handling Dan Carpenter
  -- strict thread matches above, loose matches on Subject: below --
2015-03-05 11:24 Dan Carpenter
2015-03-06 18:30 ` Konrad Rzeszutek Wilk
2015-03-06 18:30 ` Konrad Rzeszutek Wilk
2015-03-16 14:47 ` David Vrabel

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.