From bdb5c71712c8f1c04cdf3dc3d1ac26038acfb026 Mon Sep 17 00:00:00 2001 From: zhanghongyu Date: Wed, 21 Jan 2026 08:32:17 +0800 Subject: [PATCH] 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 --- 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 abd7b6cc7611f..35d0e116f2836 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 7832b61ede769..ba0b23dab8ce2 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 */