All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 2/3] X25: Check for errors in x25_init
@ 2009-11-25  1:15 andrew hendry
  2009-11-30  7:41 ` Simon Horman
  0 siblings, 1 reply; 2+ messages in thread
From: andrew hendry @ 2009-11-25  1:15 UTC (permalink / raw)
  To: netdev; +Cc: linux-kernel, linux-x25

Adds error checking to x25_init.

Signed-off-by: Andrew Hendry <andrew.hendry@gmail.com>

diff -uprN -X a/Documentation/dontdiff a/net/x25/af_x25.c b/net/x25/af_x25.c
--- a/net/x25/af_x25.c  2009-11-25 10:21:17.000000000 +1100
+++ b/net/x25/af_x25.c  2009-11-25 10:22:06.000000000 +1100
@@ -1659,18 +1659,31 @@ static int __init x25_init(void)
 	if (rc != 0)
 		goto out;

-	sock_register(&x25_family_ops);
+	rc = sock_register(&x25_family_ops);
+	if (rc != 0)
+		goto out_proto;

 	dev_add_pack(&x25_packet_type);

-	register_netdevice_notifier(&x25_dev_notifier);
+	rc = register_netdevice_notifier(&x25_dev_notifier);
+	if (rc != 0)
+		goto out_sock;

 	printk(KERN_INFO "X.25 for Linux Version 0.2\n");

 	x25_register_sysctl();
-	x25_proc_init();
+	rc = x25_proc_init();
+	if (rc != 0)
+		goto out_dev;
 out:
 	return rc;
+out_dev:
+	unregister_netdevice_notifier(&x25_dev_notifier);
+out_sock:
+	sock_unregister(AF_X25);
+out_proto:
+	proto_unregister(&x25_proto);
+	goto out;
 }
 module_init(x25_init);

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

* Re: [PATCH 2/3] X25: Check for errors in x25_init
  2009-11-25  1:15 [PATCH 2/3] X25: Check for errors in x25_init andrew hendry
@ 2009-11-30  7:41 ` Simon Horman
  0 siblings, 0 replies; 2+ messages in thread
From: Simon Horman @ 2009-11-30  7:41 UTC (permalink / raw)
  To: andrew hendry; +Cc: netdev, linux-kernel, linux-x25

On Wed, Nov 25, 2009 at 12:15:42PM +1100, andrew hendry wrote:
> Adds error checking to x25_init.
> 
> Signed-off-by: Andrew Hendry <andrew.hendry@gmail.com>
> 
> diff -uprN -X a/Documentation/dontdiff a/net/x25/af_x25.c b/net/x25/af_x25.c
> --- a/net/x25/af_x25.c  2009-11-25 10:21:17.000000000 +1100
> +++ b/net/x25/af_x25.c  2009-11-25 10:22:06.000000000 +1100
> @@ -1659,18 +1659,31 @@ static int __init x25_init(void)
>  	if (rc != 0)
>  		goto out;
> 
> -	sock_register(&x25_family_ops);
> +	rc = sock_register(&x25_family_ops);
> +	if (rc != 0)
> +		goto out_proto;
> 
>  	dev_add_pack(&x25_packet_type);
> 
> -	register_netdevice_notifier(&x25_dev_notifier);
> +	rc = register_netdevice_notifier(&x25_dev_notifier);
> +	if (rc != 0)
> +		goto out_sock;
> 
>  	printk(KERN_INFO "X.25 for Linux Version 0.2\n");
> 
>  	x25_register_sysctl();
> -	x25_proc_init();
> +	rc = x25_proc_init();
> +	if (rc != 0)
> +		goto out_dev;
>  out:
>  	return rc;
> +out_dev:
> +	unregister_netdevice_notifier(&x25_dev_notifier);
> +out_sock:
> +	sock_unregister(AF_X25);
> +out_proto:
> +	proto_unregister(&x25_proto);
> +	goto out;
>  }
>  module_init(x25_init);

The following seems slightly cleaner to me:

...
	rc = x25_proc_init();
	if (rc != 0)
		goto out_dev;

	return 0;  <-- or goto out;
out_dev:
	unregister_netdevice_notifier(&x25_dev_notifier);
out_sock:
	sock_unregister(AF_X25);
out_proto:
	proto_unregister(&x25_proto);
out:
	return rc;
}


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

end of thread, other threads:[~2009-11-30  8:01 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-11-25  1:15 [PATCH 2/3] X25: Check for errors in x25_init andrew hendry
2009-11-30  7:41 ` Simon Horman

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.