This is an automated email from the ASF dual-hosted git repository.
xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
The following commit(s) were added to refs/heads/master by this push:
new 646010d0a0c net/bluetooth: fix rmutex deadlock
646010d0a0c is described below
commit 646010d0a0ca29dcf253dd75670541df78db32b2
Author: zhanghongyu <[email protected]>
AuthorDate: Wed Jan 21 08:32:17 2026 +0800
net/bluetooth: fix rmutex deadlock
the lock in the "bluetooth_conn" was not initialized, which resulted in
a blocking situation when attempting to hold the lock for the first
time.
Signed-off-by: zhanghongyu <[email protected]>
---
net/bluetooth/bluetooth_conn.c | 2 ++
net/bluetooth/bluetooth_sockif.c | 1 +
2 files changed, 3 insertions(+)
diff --git a/net/bluetooth/bluetooth_conn.c b/net/bluetooth/bluetooth_conn.c
index abd7b6cc761..35d0e116f28 100644
--- a/net/bluetooth/bluetooth_conn.c
+++ b/net/bluetooth/bluetooth_conn.c
@@ -166,6 +166,8 @@ void bluetooth_conn_free(FAR struct bluetooth_conn_s *conn)
bluetooth_container_free(container);
}
+ nxrmutex_destroy(&conn->bc_conn.s_lock);
+
/* Free the connection structure */
NET_BUFPOOL_FREE(g_bluetooth_connections, conn);
diff --git a/net/bluetooth/bluetooth_sockif.c b/net/bluetooth/bluetooth_sockif.c
index 7832b61ede7..ba0b23dab8c 100644
--- a/net/bluetooth/bluetooth_sockif.c
+++ b/net/bluetooth/bluetooth_sockif.c
@@ -127,6 +127,7 @@ static int bluetooth_sockif_alloc(FAR struct socket *psock)
DEBUGASSERT(conn->bc_crefs == 0);
conn->bc_crefs = 1;
+ nxrmutex_init(&conn->bc_conn.s_lock);
/* Save the pre-allocated connection in the socket structure */