neighbour: populate neigh_parms on alloc before calling ndo_neigh_setup
authorVeaceslav Falico <vfalico@redhat.com>
Fri, 2 Aug 2013 17:07:38 +0000 (19:07 +0200)
committerDavid S. Miller <davem@davemloft.net>
Fri, 2 Aug 2013 22:44:23 +0000 (15:44 -0700)
dev->ndo_neigh_setup() might need some of the values of neigh_parms, so
populate them before calling it.

Signed-off-by: Veaceslav Falico <vfalico@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/core/neighbour.c

index b7de821f98df2875dd5c4c7b08f32b2f3d7f98a2..576d46f4a69ef88cc27dff3efccdf7bf83d43313 100644 (file)
@@ -1441,16 +1441,18 @@ struct neigh_parms *neigh_parms_alloc(struct net_device *dev,
                atomic_set(&p->refcnt, 1);
                p->reachable_time =
                                neigh_rand_reach_time(p->base_reachable_time);
+               dev_hold(dev);
+               p->dev = dev;
+               write_pnet(&p->net, hold_net(net));
+               p->sysctl_table = NULL;
 
                if (ops->ndo_neigh_setup && ops->ndo_neigh_setup(dev, p)) {
+                       release_net(net);
+                       dev_put(dev);
                        kfree(p);
                        return NULL;
                }
 
-               dev_hold(dev);
-               p->dev = dev;
-               write_pnet(&p->net, hold_net(net));
-               p->sysctl_table = NULL;
                write_lock_bh(&tbl->lock);
                p->next         = tbl->parms.next;
                tbl->parms.next = p;