Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net
[linux-2.6-microblaze.git] / net / ipv6 / sit.c
index 63ccd9f..aa98294 100644 (file)
@@ -218,8 +218,6 @@ static int ipip6_tunnel_create(struct net_device *dev)
 
        ipip6_tunnel_clone_6rd(dev, sitn);
 
-       dev_hold(dev);
-
        ipip6_tunnel_link(sitn, t);
        return 0;
 
@@ -325,7 +323,7 @@ static int ipip6_tunnel_get_prl(struct net_device *dev, struct ifreq *ifr)
 
        rcu_read_lock();
 
-       ca = t->prl_count < cmax ? t->prl_count : cmax;
+       ca = min(t->prl_count, cmax);
 
        if (!kp) {
                /* We don't try hard to allocate much memory for
@@ -1456,7 +1454,7 @@ static int ipip6_tunnel_init(struct net_device *dev)
                dev->tstats = NULL;
                return err;
        }
-
+       dev_hold(dev);
        return 0;
 }
 
@@ -1472,7 +1470,6 @@ static void __net_init ipip6_fb_tunnel_init(struct net_device *dev)
        iph->ihl                = 5;
        iph->ttl                = 64;
 
-       dev_hold(dev);
        rcu_assign_pointer(sitn->tunnels_wc[0], tunnel);
 }
 
@@ -1867,9 +1864,9 @@ static void __net_exit sit_destroy_tunnels(struct net *net,
                if (dev->rtnl_link_ops == &sit_link_ops)
                        unregister_netdevice_queue(dev, head);
 
-       for (prio = 1; prio < 4; prio++) {
+       for (prio = 0; prio < 4; prio++) {
                int h;
-               for (h = 0; h < IP6_SIT_HASH_SIZE; h++) {
+               for (h = 0; h < (prio ? IP6_SIT_HASH_SIZE : 1); h++) {
                        struct ip_tunnel *t;
 
                        t = rtnl_dereference(sitn->tunnels[prio][h]);