From be70ab2ebb07f4c6fad99492b6754d06435edb28 Mon Sep 17 00:00:00 2001 From: ligd Date: Fri, 3 Dec 2021 20:38:34 +0800 Subject: [PATCH] rpmsg_scoket: handle race condition on ept_cb RPMSG_SOCKET_CMD_SYNC Signed-off-by: ligd --- net/rpmsg/rpmsg_sockif.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/net/rpmsg/rpmsg_sockif.c b/net/rpmsg/rpmsg_sockif.c index 5ce5021ff1..e1d547f4f8 100644 --- a/net/rpmsg/rpmsg_sockif.c +++ b/net/rpmsg/rpmsg_sockif.c @@ -296,9 +296,11 @@ static int rpmsg_socket_ept_cb(FAR struct rpmsg_endpoint *ept, if (head->cmd == RPMSG_SOCKET_CMD_SYNC) { + rpmsg_socket_lock(&conn->recvlock); conn->sendsize = head->size; conn->psock->s_flags |= _SF_CONNECTED; _SO_SETERRNO(conn->psock, OK); + rpmsg_socket_unlock(&conn->recvlock); rpmsg_socket_post(&conn->sendsem); rpmsg_socket_pollnotify(conn, POLLOUT); }