From: Simon Horman <horms@verge.net.au>
To: andrew hendry <andrew.hendry@gmail.com>
Cc: netdev@vger.kernel.org,
linux-kernel <linux-kernel@vger.kernel.org>,
linux-x25@vger.kernel.org
Subject: Re: [PATCH 2/3] X25: Check for errors in x25_init
Date: Mon, 30 Nov 2009 18:41:25 +1100 [thread overview]
Message-ID: <20091130074125.GA9541@verge.net.au> (raw)
In-Reply-To: <d45a3acc0911241715k6882aa3el64a50b3d68d12167@mail.gmail.com>
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;
}
prev parent reply other threads:[~2009-11-30 8:01 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-11-25 1:15 andrew hendry
2009-11-30 7:41 ` Simon Horman [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=20091130074125.GA9541@verge.net.au \
--to=horms@verge.net.au \
--cc=andrew.hendry@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-x25@vger.kernel.org \
--cc=netdev@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
all inboxes | Powered by JetHome®