Skip to content

Commit b8fedfb

Browse files
MarekPietaMaureenHelm
authored andcommitted
bluetooth: host: conn: Fix assertion failure in wait_for_tx_work
Calling bt_disable in system workqueue context while BLE connected may lead to calling wait_for_tx_work in this context. Fix check in code to avoid assertion failure. Signed-off-by: Marek Pieta <[email protected]>
1 parent 423f18c commit b8fedfb

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

subsys/bluetooth/host/conn.c

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -383,18 +383,13 @@ static void wait_for_tx_work(struct bt_conn *conn)
383383
#if defined(CONFIG_BT_CONN_TX)
384384
LOG_DBG("conn %p", conn);
385385

386-
if (IS_ENABLED(CONFIG_BT_RECV_WORKQ_SYS)) {
386+
if (IS_ENABLED(CONFIG_BT_RECV_WORKQ_SYS) ||
387+
k_current_get() == k_work_queue_thread_get(&k_sys_work_q)) {
387388
tx_notify(conn);
388389
} else {
389390
struct k_work_sync sync;
390391
int err;
391392

392-
/* API docs mention undefined behavior if syncing on work item
393-
* from wq execution context.
394-
*/
395-
__ASSERT_NO_MSG(k_current_get() !=
396-
k_work_queue_thread_get(&k_sys_work_q));
397-
398393
err = k_work_submit(&conn->tx_complete_work);
399394
__ASSERT(err >= 0, "couldn't submit (err %d)", err);
400395

0 commit comments

Comments
 (0)