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 c1297875fc396515a13b381f3c2e1a7e038f604d Author: chenzihan1 <[email protected]> AuthorDate: Mon Apr 27 11:21:34 2026 +0800 net/rpmsg: free the unaccepted connections when a listener closes Closing a listening socket detached the connections still waiting for their SYNC, but left the ones that had completed the handshake and were queued for accept() on server->next. Nothing refers to them after the listener is freed, so their endpoints and memory leaked, and the peer kept a connection nobody would ever read. Destroy them as well, clearing crefs first so that release_cb frees them. Signed-off-by: chenzihan1 <[email protected]> Signed-off-by: Bowen Wang <[email protected]> --- net/rpmsg/rpmsg_sockif.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/net/rpmsg/rpmsg_sockif.c b/net/rpmsg/rpmsg_sockif.c index 0b1cc354d50..aa1b10b23db 100644 --- a/net/rpmsg/rpmsg_sockif.c +++ b/net/rpmsg/rpmsg_sockif.c @@ -1670,6 +1670,7 @@ static int rpmsg_socket_close(FAR struct socket *psock) if (conn->backlog > 0) { + FAR struct rpmsg_socket_conn_s *child; FAR struct rpmsg_socket_conn_s *pend; nxmutex_lock(&g_rpmsg_socket_lock); @@ -1703,7 +1704,23 @@ static int rpmsg_socket_close(FAR struct socket *psock) nxmutex_lock(&conn->recvlock); } + /* Drop the connections that completed the handshake but were never + * accepted. Nothing else refers to them. + */ + + child = conn->next; + conn->next = NULL; nxmutex_unlock(&conn->recvlock); + + while (child != NULL) + { + FAR struct rpmsg_socket_conn_s *next = child->next; + + child->next = NULL; + child->crefs = 0; + rpmsg_socket_destroy_ept(child); + child = next; + } } else {
