Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

net: remove obsolete WARN_ON(refcount_read(&sk->sk_refcnt) == 1)

sk->sk_refcnt has been converted to refcount_t in 2017.

__sock_put(sk) being refcount_dec(&sk->sk_refcnt), it will complain
loudly if the current refcnt is 1 (or less) in a non racy way.

We can remove four WARN_ON() in favor of the generic refcount_dec()
check.

Signed-off-by: Eric Dumazet <edumazet@google.com>
Reviewed-by: Kuniyuki Iwashima <kuniyu@google.com>
Reviewed-by: Xuanqiang Luo<luoxuanqiang@kylinos.cn>
Link: https://patch.msgid.link/20251014140605.2982703-1-edumazet@google.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Eric Dumazet and committed by
Jakub Kicinski
e5b670e5 378e6523

+6 -14
+4 -8
include/net/sock.h
··· 830 830 { 831 831 bool rc = __sk_del_node_init(sk); 832 832 833 - if (rc) { 834 - /* paranoid for a while -acme */ 835 - WARN_ON(refcount_read(&sk->sk_refcnt) == 1); 833 + if (rc) 836 834 __sock_put(sk); 837 - } 835 + 838 836 return rc; 839 837 } 840 838 #define sk_del_node_init_rcu(sk) sk_del_node_init(sk) ··· 850 852 { 851 853 bool rc = __sk_nulls_del_node_init_rcu(sk); 852 854 853 - if (rc) { 854 - /* paranoid for a while -acme */ 855 - WARN_ON(refcount_read(&sk->sk_refcnt) == 1); 855 + if (rc) 856 856 __sock_put(sk); 857 - } 857 + 858 858 return rc; 859 859 } 860 860
+1 -3
net/netlink/af_netlink.c
··· 596 596 597 597 table = &nl_table[sk->sk_protocol]; 598 598 if (!rhashtable_remove_fast(&table->hash, &nlk_sk(sk)->node, 599 - netlink_rhashtable_params)) { 600 - WARN_ON(refcount_read(&sk->sk_refcnt) == 1); 599 + netlink_rhashtable_params)) 601 600 __sock_put(sk); 602 - } 603 601 604 602 netlink_table_grab(); 605 603 if (nlk_sk(sk)->subscriptions) {
+1 -3
net/tipc/socket.c
··· 3031 3031 struct sock *sk = &tsk->sk; 3032 3032 struct tipc_net *tn = net_generic(sock_net(sk), tipc_net_id); 3033 3033 3034 - if (!rhashtable_remove_fast(&tn->sk_rht, &tsk->node, tsk_rht_params)) { 3035 - WARN_ON(refcount_read(&sk->sk_refcnt) == 1); 3034 + if (!rhashtable_remove_fast(&tn->sk_rht, &tsk->node, tsk_rht_params)) 3036 3035 __sock_put(sk); 3037 - } 3038 3036 } 3039 3037 3040 3038 static const struct rhashtable_params tsk_rht_params = {