Skip to content

Commit 379eb7a

Browse files
fredrikdanebjerkartben
authored andcommitted
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 94a8c52 commit 379eb7a

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
@@ -598,8 +598,6 @@ static void hci_num_completed_packets(struct net_buf *buf)
598598
while (count--) {
599599
sys_snode_t *node;
600600

601-
k_sem_give(bt_conn_get_pkts(conn));
602-
603601
/* move the next TX context from the `pending` list to
604602
* the `complete` list.
605603
*/
@@ -611,6 +609,8 @@ static void hci_num_completed_packets(struct net_buf *buf)
611609
break;
612610
}
613611

612+
k_sem_give(bt_conn_get_pkts(conn));
613+
614614
sys_slist_append(&conn->tx_complete, node);
615615

616616
/* align the `pending` value */

0 commit comments

Comments
 (0)