Skip to content

Commit df12b0e

Browse files
committed
Bluetooth: ISO: Fix issue with BIS tx_complete
BIS termination as broadcaster is handled different than ACL and CIS, and in rare chances the tx_complete for BIS may not have been completed in the system workqueue before iso_new was called for the same bt_conn struct (e.g. via bt_iso_cig_create), which would perform k_work_init(&conn->tx_complete_work, tx_complete_work); but where conn->tx_complete_work still existed in the system workqueue, which would cause the list of pending items on the system workqueue to be removed as the `next` pointer would be NULL. This also adds an assert in bt_conn_new to prevent this issue from appearing again. Signed-off-by: Emil Gydesen <[email protected]>
1 parent 31ef45e commit df12b0e

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

subsys/bluetooth/host/conn.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,8 @@ struct bt_conn *bt_conn_new(struct bt_conn *conns, size_t size)
372372
k_work_init_delayable(&conn->deferred_work, deferred_work);
373373
#endif /* CONFIG_BT_CONN */
374374
#if defined(CONFIG_BT_CONN_TX)
375+
__ASSERT(!k_work_is_pending(&conn->tx_complete_work),
376+
"tx_complete_work is pending, performing k_work_init will break the workqueue");
375377
k_work_init(&conn->tx_complete_work, tx_complete_work);
376378
#endif /* CONFIG_BT_CONN_TX */
377379

subsys/bluetooth/host/iso.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -511,6 +511,15 @@ static void bt_iso_chan_disconnected(struct bt_iso_chan *chan, uint8_t reason)
511511
}
512512
#endif /* CONFIG_BT_ISO_CENTRAL */
513513
}
514+
} else if (IS_ENABLED(CONFIG_BT_ISO_BROADCASTER) &&
515+
conn_type == BT_ISO_CHAN_TYPE_BROADCASTER) {
516+
/* BIS do not get a HCI Disconnected event and will not handle cleanup of pending TX
517+
* complete in the same way as ACL and CIS do. Call bt_conn_tx_notify directly here
518+
* to flush the chan->iso->tx_complete for each disconnected BIS
519+
*/
520+
bt_conn_tx_notify(chan->iso, true);
521+
} else {
522+
/* No special handling for BT_ISO_CHAN_TYPE_SYNC_RECEIVER */
514523
}
515524
}
516525

0 commit comments

Comments
 (0)