--- x/net/netrom/nr_route.c +++ y/net/netrom/nr_route.c @@ -465,11 +465,9 @@ static int nr_dec_obs(void) case 1: /* From 1 -> 0 */ nr_neigh = s->routes[i].neighbour; - nr_neigh->count--; - nr_neigh_put(nr_neigh); - - if (nr_neigh->count == 0 && !nr_neigh->locked) + if (--nr_neigh->count == 0 && !nr_neigh->locked) nr_remove_neigh(nr_neigh); + nr_neigh_put(nr_neigh); s->count--; @@ -511,9 +509,12 @@ void nr_rt_device_down(struct net_device struct nr_node *t; int i; +loop: spin_lock_bh(&nr_neigh_list_lock); nr_neigh_for_each_safe(s, nodet, &nr_neigh_list) { if (s->dev == dev) { + nr_remove_neigh_locked(s); + spin_unlock_bh(&nr_neigh_list_lock); spin_lock_bh(&nr_node_list_lock); nr_node_for_each_safe(t, node2t, &nr_node_list) { nr_node_lock(t); @@ -539,8 +540,7 @@ void nr_rt_device_down(struct net_device nr_node_unlock(t); } spin_unlock_bh(&nr_node_list_lock); - - nr_remove_neigh_locked(s); + goto loop; } } spin_unlock_bh(&nr_neigh_list_lock);