static int mptcp_disconnect(struct sock *sk, int flags);
 
-static int mptcp_sendmsg_fastopen(struct sock *sk, struct sock *ssk, struct msghdr *msg,
+static int mptcp_sendmsg_fastopen(struct sock *sk, struct msghdr *msg,
                                  size_t len, int *copied_syn)
 {
        unsigned int saved_flags = msg->msg_flags;
        struct mptcp_sock *msk = mptcp_sk(sk);
+       struct sock *ssk;
        int ret;
 
+       /* on flags based fastopen the mptcp is supposed to create the
+        * first subflow right now. Otherwise we are in the defer_connect
+        * path, and the first subflow must be already present.
+        * Since the defer_connect flag is cleared after the first succsful
+        * fastopen attempt, no need to check for additional subflow status.
+        */
+       if (msg->msg_flags & MSG_FASTOPEN && !__mptcp_nmpc_socket(msk))
+               return -EINVAL;
+       if (!msk->first)
+               return -EINVAL;
+
+       ssk = msk->first;
+
        lock_sock(ssk);
        msg->msg_flags |= MSG_DONTWAIT;
        msk->connect_flags = O_NONBLOCK;
        } else if (ret && ret != -EINPROGRESS) {
                mptcp_disconnect(sk, 0);
        }
+       inet_sk(sk)->defer_connect = 0;
 
        return ret;
 }
 {
        struct mptcp_sock *msk = mptcp_sk(sk);
        struct page_frag *pfrag;
-       struct socket *ssock;
        size_t copied = 0;
        int ret = 0;
        long timeo;
 
        lock_sock(sk);
 
-       ssock = __mptcp_nmpc_socket(msk);
-       if (unlikely(ssock && (inet_sk(ssock->sk)->defer_connect ||
-                              msg->msg_flags & MSG_FASTOPEN))) {
+       if (unlikely(inet_sk(sk)->defer_connect || msg->msg_flags & MSG_FASTOPEN)) {
                int copied_syn = 0;
 
-               ret = mptcp_sendmsg_fastopen(sk, ssock->sk, msg, len, &copied_syn);
+               ret = mptcp_sendmsg_fastopen(sk, msg, len, &copied_syn);
                copied += copied_syn;
                if (ret == -EINPROGRESS && copied_syn > 0)
                        goto out;