Suggestion of @mmartineau : 'add locks' is implemented in this patch
Signed-off-by: Dmytro Shytyi <dmytro@shytyi.net>
---
net/mptcp/fastopen.c | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/net/mptcp/fastopen.c b/net/mptcp/fastopen.c
index 9974508e0f4c..50b5c3376672 100644
--- a/net/mptcp/fastopen.c
+++ b/net/mptcp/fastopen.c
@@ -16,6 +16,7 @@ int mptcp_sendmsg_fastopen(struct sock *sk, struct msghdr *msg,
struct socket *ssk;
int ret;
+ lock_sock((struct sock *)msk);
ssk = __mptcp_nmpc_socket(msk);
if (unlikely(!ssk))
goto out_EFAULT;
@@ -30,26 +31,35 @@ int mptcp_sendmsg_fastopen(struct sock *sk, struct msghdr *msg,
goto out_EFAULT;
uaddr = msg->msg_name;
+ lock_sock(ssk->sk);
+
tp = tcp_sk(ssk->sk);
if (unlikely(!tp))
- goto out_EFAULT;
+ goto out_lock_EFAULT;
if (!tp->fastopen_req)
tp->fastopen_req = kzalloc(sizeof(*tp->fastopen_req),
ssk->sk->sk_allocation);
if (unlikely(!tp->fastopen_req))
- goto out_EFAULT;
+ goto out_lock_EFAULT;
tp->fastopen_req->data = msg;
tp->fastopen_req->size = len;
tp->fastopen_req->uarg = uarg;
+ release_sock(ssk->sk);
+ release_sock((struct sock *)msk);
+
/* requests a cookie */
ret = mptcp_stream_connect(sk->sk_socket, uaddr,
msg->msg_namelen, msg->msg_flags);
if (!ret)
*copied = len;
return ret;
+
+out_lock_EFAULT:
+ release_sock(ssk->sk);
out_EFAULT:
+ release_sock((struct sock *)msk);
ret = -EFAULT;
return ret;
}
--
2.25.1