@@ -3594,7 +3594,6 @@ static int mptcp_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len)
if (IS_ERR(ssock))
return PTR_ERR(ssock);
- mptcp_token_destroy(msk);
inet_sk_state_store(sk, TCP_SYN_SENT);
subflow = mptcp_subflow_ctx(ssock->sk);
#ifdef CONFIG_TCP_MD5SIG
@@ -3624,6 +3623,8 @@ static int mptcp_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len)
* subflow_finish_connect()
*/
if (unlikely(err && err != -EINPROGRESS)) {
+ /* avoid leaving a dangling token in an unconnected socket */
+ mptcp_token_destroy(msk);
inet_sk_state_store(sk, inet_sk_state_load(ssock->sk));
return err;
}
@@ -3713,7 +3714,6 @@ static int mptcp_listen(struct socket *sock, int backlog)
goto unlock;
}
- mptcp_token_destroy(msk);
inet_sk_state_store(sk, TCP_LISTEN);
sock_set_flag(sk, SOCK_RCU_FREE);