Skip to content

Commit 55fb80d

Browse files
Eric Dumazetkuba-moo
authored andcommitted
tcp: use 2-arg optimal variant of kfree_rcu()
kfree_rcu(1-arg) should be avoided as much as possible, since this is only possible from sleepable contexts, and incurr extra rcu barriers. I wish the 1-arg variant of kfree_rcu() would get a distinct name, like kfree_rcu_slow() to avoid it being abused. Fixes: 459837b ("net/tcp: Disable TCP-MD5 static key on tcp_md5sig_info destruction") Signed-off-by: Eric Dumazet <[email protected]> Cc: Paul E. McKenney <[email protected]> Reviewed-by: Pavan Chebbi <[email protected]> Reviewed-by: Dmitry Safonov <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent edd4e25 commit 55fb80d

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

net/ipv4/tcp_ipv4.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1245,7 +1245,7 @@ int tcp_md5_do_add(struct sock *sk, const union tcp_md5_addr *addr,
12451245

12461246
md5sig = rcu_dereference_protected(tp->md5sig_info, lockdep_sock_is_held(sk));
12471247
rcu_assign_pointer(tp->md5sig_info, NULL);
1248-
kfree_rcu(md5sig);
1248+
kfree_rcu(md5sig, rcu);
12491249
return -EUSERS;
12501250
}
12511251
}
@@ -1271,7 +1271,7 @@ int tcp_md5_key_copy(struct sock *sk, const union tcp_md5_addr *addr,
12711271
md5sig = rcu_dereference_protected(tp->md5sig_info, lockdep_sock_is_held(sk));
12721272
net_warn_ratelimited("Too many TCP-MD5 keys in the system\n");
12731273
rcu_assign_pointer(tp->md5sig_info, NULL);
1274-
kfree_rcu(md5sig);
1274+
kfree_rcu(md5sig, rcu);
12751275
return -EUSERS;
12761276
}
12771277
}

0 commit comments

Comments
 (0)