This is an automated email from the ASF dual-hosted git repository.

xiaoxiang781216 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git

commit f3fe182ffe35f829986445b17bb7793858d1408b
Author: zhangbo56 <[email protected]>
AuthorDate: Sun Jan 26 18:41:08 2025 +0800

    net/rpmsg: Fix a race condition in poll
    
    Not only in poll_setup, ept callback will also call poll_notify,
    which may cause a all zero revents returned to user space. Fix it
    by holding a mutex.
    
    Signed-off-by: zhangbo56 <[email protected]>
---
 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 b23422fdc92..69b4d1457bc 100644
--- a/net/rpmsg/rpmsg_sockif.c
+++ b/net/rpmsg/rpmsg_sockif.c
@@ -983,7 +983,9 @@ static int rpmsg_socket_poll(FAR struct socket *psock,
             }
         }
 
+      nxmutex_lock(&conn->polllock);
       poll_notify(&fds, 1, eventset);
+      nxmutex_unlock(&conn->polllock);
     }
   else
     {

Reply via email to