summaryrefslogtreecommitdiff
path: root/net/core/neighbour.c
diff options
context:
space:
mode:
authorPavel Emelyanov <xemul@openvz.org>2007-12-02 00:06:34 +1100
committerDavid S. Miller <davem@davemloft.net>2008-01-28 14:55:24 -0800
commit3c607bbb472814f01b077af01ae326944ff6b8b3 (patch)
tree0b6097274f25c8c0cfe180c8da640c68c9781af6 /net/core/neighbour.c
parent1597fbc0faf88c42edb3fe42e92e53b83c3f120e (diff)
downloadlwn-3c607bbb472814f01b077af01ae326944ff6b8b3.tar.gz
lwn-3c607bbb472814f01b077af01ae326944ff6b8b3.zip
[NEIGH]: Cleanup the neigh_sysctl_register
This mainly removes the err variable, as this call always return the same error code (-ENOBUFS). Besides, I moved the call to kmalloc() from the *t declaration into the code (this is confusing when a variable is initialized with the result of some call) and removed unneeded comment near the error path. Signed-off-by: Pavel Emelyanov <xemul@openvz.org> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/core/neighbour.c')
-rw-r--r--net/core/neighbour.c26
1 files changed, 11 insertions, 15 deletions
diff --git a/net/core/neighbour.c b/net/core/neighbour.c
index a8b72c1c7c8a..5dbe26f460d6 100644
--- a/net/core/neighbour.c
+++ b/net/core/neighbour.c
@@ -2652,14 +2652,14 @@ int neigh_sysctl_register(struct net_device *dev, struct neigh_parms *p,
int p_id, int pdev_id, char *p_name,
proc_handler *handler, ctl_handler *strategy)
{
- struct neigh_sysctl_table *t = kmemdup(&neigh_sysctl_template,
- sizeof(*t), GFP_KERNEL);
+ struct neigh_sysctl_table *t;
const char *dev_name_source = NULL;
char *dev_name = NULL;
- int err = 0;
+ t = kmemdup(&neigh_sysctl_template, sizeof(*t), GFP_KERNEL);
if (!t)
- return -ENOBUFS;
+ goto err;
+
t->neigh_vars[0].data = &p->mcast_probes;
t->neigh_vars[1].data = &p->ucast_probes;
t->neigh_vars[2].data = &p->app_probes;
@@ -2717,10 +2717,8 @@ int neigh_sysctl_register(struct net_device *dev, struct neigh_parms *p,
}
dev_name = kstrdup(dev_name_source, GFP_KERNEL);
- if (!dev_name) {
- err = -ENOBUFS;
+ if (!dev_name)
goto free;
- }
t->neigh_dev[0].procname = dev_name;
@@ -2735,20 +2733,18 @@ int neigh_sysctl_register(struct net_device *dev, struct neigh_parms *p,
t->neigh_root_dir[0].child = t->neigh_proto_dir;
t->sysctl_header = register_sysctl_table(t->neigh_root_dir);
- if (!t->sysctl_header) {
- err = -ENOBUFS;
+ if (!t->sysctl_header)
goto free_procname;
- }
+
p->sysctl_table = t;
return 0;
- /* error path */
- free_procname:
+free_procname:
kfree(dev_name);
- free:
+free:
kfree(t);
-
- return err;
+err:
+ return -ENOBUFS;
}
void neigh_sysctl_unregister(struct neigh_parms *p)