net: use WARN_ON_ONCE() in inet_sock_destruct()
authorEric Dumazet <edumazet@google.com>
Wed, 8 Jun 2022 16:04:33 +0000 (09:04 -0700)
committerJakub Kicinski <kuba@kernel.org>
Fri, 10 Jun 2022 04:53:55 +0000 (21:53 -0700)
inet_sock_destruct() has four warnings which have been
useful to point to kernel bugs in the past.

However they are potentially a problem because they
could flood the syslog.

Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
net/ipv4/af_inet.c

index 93da9f7..30e0e89 100644 (file)
@@ -148,10 +148,10 @@ void inet_sock_destruct(struct sock *sk)
                return;
        }
 
-       WARN_ON(atomic_read(&sk->sk_rmem_alloc));
-       WARN_ON(refcount_read(&sk->sk_wmem_alloc));
-       WARN_ON(sk->sk_wmem_queued);
-       WARN_ON(sk_forward_alloc_get(sk));
+       WARN_ON_ONCE(atomic_read(&sk->sk_rmem_alloc));
+       WARN_ON_ONCE(refcount_read(&sk->sk_wmem_alloc));
+       WARN_ON_ONCE(sk->sk_wmem_queued);
+       WARN_ON_ONCE(sk_forward_alloc_get(sk));
 
        kfree(rcu_dereference_protected(inet->inet_opt, 1));
        dst_release(rcu_dereference_protected(sk->sk_dst_cache, 1));