Skip to content

Commit 9fa8964

Browse files
xemuldavem330
authored andcommitted
[IPV4]: Cleanup the devinet_sysctl_register
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. Just like I did with the neigh ctl-s. Besides, I fixed the goto's and the labels - they were indented with spaces :( 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>
1 parent c3bac5a commit 9fa8964

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

net/ipv4/devinet.c

+9-8
Original file line numberDiff line numberDiff line change
@@ -1506,12 +1506,13 @@ static void devinet_sysctl_register(struct in_device *in_dev,
15061506
{
15071507
int i;
15081508
struct net_device *dev = in_dev ? in_dev->dev : NULL;
1509-
struct devinet_sysctl_table *t = kmemdup(&devinet_sysctl, sizeof(*t),
1510-
GFP_KERNEL);
1509+
struct devinet_sysctl_table *t;
15111510
char *dev_name = NULL;
15121511

1512+
t = kmemdup(&devinet_sysctl, sizeof(*t), GFP_KERNEL);
15131513
if (!t)
1514-
return;
1514+
goto out;
1515+
15151516
for (i = 0; i < ARRAY_SIZE(t->devinet_vars) - 1; i++) {
15161517
t->devinet_vars[i].data += (char *)p - (char *)&ipv4_devconf;
15171518
t->devinet_vars[i].extra1 = p;
@@ -1532,7 +1533,7 @@ static void devinet_sysctl_register(struct in_device *in_dev,
15321533
*/
15331534
dev_name = kstrdup(dev_name, GFP_KERNEL);
15341535
if (!dev_name)
1535-
goto free;
1536+
goto free;
15361537

15371538
t->devinet_dev[0].procname = dev_name;
15381539
t->devinet_dev[0].child = t->devinet_vars;
@@ -1542,16 +1543,16 @@ static void devinet_sysctl_register(struct in_device *in_dev,
15421543

15431544
t->sysctl_header = register_sysctl_table(t->devinet_root_dir);
15441545
if (!t->sysctl_header)
1545-
goto free_procname;
1546+
goto free_procname;
15461547

15471548
p->sysctl = t;
15481549
return;
15491550

1550-
/* error path */
1551-
free_procname:
1551+
free_procname:
15521552
kfree(dev_name);
1553-
free:
1553+
free:
15541554
kfree(t);
1555+
out:
15551556
return;
15561557
}
15571558

0 commit comments

Comments
 (0)