diff --git a/net/ipv4/inet_diag.c b/net/ipv4/inet_diag.c index c10036e..0fa690c 100644 --- a/net/ipv4/inet_diag.c +++ b/net/ipv4/inet_diag.c @@ -778,10 +778,13 @@ skip_listen_ht: for (i = s_i; i < hashinfo->ehash_size; i++) { struct inet_ehash_bucket *head = &hashinfo->ehash[i]; - rwlock_t *lock = inet_ehash_lockp(hashinfo, i); + rwlock_t *lock; struct sock *sk; struct hlist_node *node; + if (hlist_empty(&head->chain) && hlist_empty(&head->twchain)) + continue; + lock = inet_ehash_lockp(hashinfo, i); if (i > s_i) s_num = 0;