diff options
| -rw-r--r-- | net/ipv4/udp.c | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c index 549114472db3..cf5ab0581eba 100644 --- a/net/ipv4/udp.c +++ b/net/ipv4/udp.c | |||
| @@ -970,16 +970,18 @@ int udp_disconnect(struct sock *sk, int flags) | |||
| 970 | 970 | ||
| 971 | void udp_lib_unhash(struct sock *sk) | 971 | void udp_lib_unhash(struct sock *sk) |
| 972 | { | 972 | { |
| 973 | struct udp_table *udptable = sk->sk_prot->h.udp_table; | 973 | if (sk_hashed(sk)) { |
| 974 | unsigned int hash = udp_hashfn(sock_net(sk), sk->sk_hash); | 974 | struct udp_table *udptable = sk->sk_prot->h.udp_table; |
| 975 | struct udp_hslot *hslot = &udptable->hash[hash]; | 975 | unsigned int hash = udp_hashfn(sock_net(sk), sk->sk_hash); |
| 976 | struct udp_hslot *hslot = &udptable->hash[hash]; | ||
| 976 | 977 | ||
| 977 | spin_lock_bh(&hslot->lock); | 978 | spin_lock_bh(&hslot->lock); |
| 978 | if (sk_nulls_del_node_init_rcu(sk)) { | 979 | if (sk_nulls_del_node_init_rcu(sk)) { |
| 979 | inet_sk(sk)->num = 0; | 980 | inet_sk(sk)->num = 0; |
| 980 | sock_prot_inuse_add(sock_net(sk), sk->sk_prot, -1); | 981 | sock_prot_inuse_add(sock_net(sk), sk->sk_prot, -1); |
| 982 | } | ||
| 983 | spin_unlock_bh(&hslot->lock); | ||
| 981 | } | 984 | } |
| 982 | spin_unlock_bh(&hslot->lock); | ||
| 983 | } | 985 | } |
| 984 | EXPORT_SYMBOL(udp_lib_unhash); | 986 | EXPORT_SYMBOL(udp_lib_unhash); |
| 985 | 987 | ||
