Skip to content

Commit c8d52e0

Browse files
bluetooth: host: Fix premature semaphore giving
There was a semaphore in hci_core which was given to early when receiving the BT_HCI_EVT_NUM_COMPLETED_PACKETS message from the controller. This would sometimes cause an assert to happen in function hci_num_completed_packets, where there would arise a mismatch in the bookkept count, and actually stored nodes. More concretely, due to premature semaphore giveing, the tx_pending node would be have been removed in another context before it could be fetched and moved to complete list in this function. Signed-off-by: Fredrik Danebjer <frdn@demant.com>
1 parent 4d848eb commit c8d52e0

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

subsys/bluetooth/host/hci_core.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -601,8 +601,6 @@ static void hci_num_completed_packets(struct net_buf *buf)
601601
while (count--) {
602602
sys_snode_t *node;
603603

604-
k_sem_give(bt_conn_get_pkts(conn));
605-
606604
/* move the next TX context from the `pending` list to
607605
* the `complete` list.
608606
*/
@@ -614,6 +612,8 @@ static void hci_num_completed_packets(struct net_buf *buf)
614612
break;
615613
}
616614

615+
k_sem_give(bt_conn_get_pkts(conn));
616+
617617
sys_slist_append(&conn->tx_complete, node);
618618

619619
/* align the `pending` value */

0 commit comments

Comments
 (0)