Skip to content

Commit e5b670e

Browse files
edumazetkuba-moo
authored andcommitted
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 <[email protected]> Reviewed-by: Kuniyuki Iwashima <[email protected]> Reviewed-by: Xuanqiang Luo<[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 378e652 commit e5b670e

File tree

3 files changed

+6
-14
lines changed

3 files changed

+6
-14
lines changed

include/net/sock.h

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -830,11 +830,9 @@ static inline bool sk_del_node_init(struct sock *sk)
830830
{
831831
bool rc = __sk_del_node_init(sk);
832832

833-
if (rc) {
834-
/* paranoid for a while -acme */
835-
WARN_ON(refcount_read(&sk->sk_refcnt) == 1);
833+
if (rc)
836834
__sock_put(sk);
837-
}
835+
838836
return rc;
839837
}
840838
#define sk_del_node_init_rcu(sk) sk_del_node_init(sk)
@@ -852,11 +850,9 @@ static inline bool sk_nulls_del_node_init_rcu(struct sock *sk)
852850
{
853851
bool rc = __sk_nulls_del_node_init_rcu(sk);
854852

855-
if (rc) {
856-
/* paranoid for a while -acme */
857-
WARN_ON(refcount_read(&sk->sk_refcnt) == 1);
853+
if (rc)
858854
__sock_put(sk);
859-
}
855+
860856
return rc;
861857
}
862858

net/netlink/af_netlink.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -596,10 +596,8 @@ static void netlink_remove(struct sock *sk)
596596

597597
table = &nl_table[sk->sk_protocol];
598598
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))
601600
__sock_put(sk);
602-
}
603601

604602
netlink_table_grab();
605603
if (nlk_sk(sk)->subscriptions) {

net/tipc/socket.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3031,10 +3031,8 @@ static void tipc_sk_remove(struct tipc_sock *tsk)
30313031
struct sock *sk = &tsk->sk;
30323032
struct tipc_net *tn = net_generic(sock_net(sk), tipc_net_id);
30333033

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))
30363035
__sock_put(sk);
3037-
}
30383036
}
30393037

30403038
static const struct rhashtable_params tsk_rht_params = {

0 commit comments

Comments
 (0)