Subject: [PATCH] nethost: cleanup __copy_host From: Eric W. Biederman Date: 1133775038 -0700 This shouldn't add any new functionality but it does make the code use the standard kernel goto error handling style for legibility and to make it easier to enhance the code. --- net/core/host.c | 38 ++++++++++++++++++++++++-------------- 1 files changed, 24 insertions(+), 14 deletions(-) 86c44237c066cb16545df1422757341fd04f5416 diff --git a/net/core/host.c b/net/core/host.c index 3b8bc93..c275a27 100644 --- a/net/core/host.c +++ b/net/core/host.c @@ -12,27 +12,37 @@ void __put_host(struct nethost *host) int __copy_host(int flags, struct task_struct *p) { + struct net_device *dev; struct nethost *host; - int result; + int err; + err = -ENOMEM; host = kzalloc(sizeof(*host), GFP_KERNEL); if (!host) - return -ENOMEM; + goto out; + atomic_set(&host->count, 1); down_read(&uts_sem); memcpy(&host->utsname, &p->host->utsname, sizeof(host->utsname)); up_read(&uts_sem); - result = loopback_init(&host->loopback_dev); - if (result != 0) { - kfree(host); - } else { - struct net_device *dev = &host->loopback_dev; - rtnl_shlock(); - if (dev_change_flags(dev, dev->flags | IFF_UP) < 0) - printk(KERN_WARNING "clone: Failed to bring up %s\n", dev->name); - rtnl_shunlock(); - p->host = host; - } - return result; + + dev = &host->loopback_dev; + err = loopback_init(dev); + if (err) + goto out_free_host; + + rtnl_shlock(); + if (dev_change_flags(dev, dev->flags | IFF_UP) < 0) + printk(KERN_WARNING "clone: Failed to bring up %s\n", dev->name); + rtnl_shunlock(); + + p->host = host; + err = 0; +out: + return err; + +out_free_host: + kfree(host); + goto out; } __init int nethost_init(void) -- 1.0.GIT