diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c index b6a38af72e1b..f2977201f8fa 100644 --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -2807,6 +2807,12 @@ static int mptcp_disconnect(struct sock *sk, int flags) struct mptcp_subflow_context *subflow; struct mptcp_sock *msk = mptcp_sk(sk); + /* Deny disconnect if other threads are blocked in sk_wait_event() + * or inet_wait_for_connect(). + */ + if (sk->sk_wait_pending) + return -EBUSY; + mptcp_do_flush_join_list(msk); mptcp_for_each_subflow(msk, subflow) { @@ -2845,6 +2851,7 @@ struct sock *mptcp_sk_clone(const struct sock *sk, inet_sk(nsk)->pinet6 = mptcp_inet6_sk(nsk); #endif + nsk->sk_wait_pending = 0; __mptcp_init_sock(nsk); msk = mptcp_sk(nsk);