From bcffcc8152eee816c59c02ae7eecccb3bedef973 Mon Sep 17 00:00:00 2001 From: Matthieu Baerts Date: Tue, 21 Feb 2023 18:54:40 +0100 Subject: [PATCH] Squash-to: DO-NOT-MERGE: mptcp: use kmalloc on kasan build This is an extra check mainly for the CIs: to make sure we don't call tcp_done() on an already closed socket as it happened in the past. If we do such call, better to catch the error earlier. This is not really related to the Squash-to patch (mptcp: use kmalloc on kasan build) but it is just not to create yet another specific commit for the CI added to both export and export-net branches. This commit can also be renamed to something like: DO-NOT-MERGE: mptcp: improve code coverage for CI WDYT? Closes: https://github.com/multipath-tcp/mptcp_net-next/issues/362 Link: https://lore.kernel.org/r/20230221-mptcp-warn-tcp-done-close-v1-2-d248242b29b6@tessares.net Signed-off-by: Matthieu Baerts --- net/ipv4/tcp.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c index 33f559f491c8c..d21ec9bdd4539 100644 --- a/net/ipv4/tcp.c +++ b/net/ipv4/tcp.c @@ -4639,6 +4639,8 @@ void tcp_done(struct sock *sk) */ req = rcu_dereference_protected(tcp_sk(sk)->fastopen_rsk, 1); + WARN_ON_ONCE(sk->sk_state == TCP_CLOSE); + if (sk->sk_state == TCP_SYN_SENT || sk->sk_state == TCP_SYN_RECV) TCP_INC_STATS(sock_net(sk), TCP_MIB_ATTEMPTFAILS);