Skip to content

Commit dda185b

Browse files
nimble/ll: Fix possible race on TX queue
Removing from ll_tx_pkt_q should be done in critical section since insertion can be done from isr. There's no need to protect peek on 1st element since we only insert in isr and remove in LL so there's no risk of element being removed after we checked not-null.
1 parent e83b12c commit dda185b

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

nimble/controller/src/ble_ll.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -711,6 +711,7 @@ ble_ll_tx_pkt_in(void)
711711
uint16_t pb;
712712
struct os_mbuf_pkthdr *pkthdr;
713713
struct os_mbuf *om;
714+
os_sr_t sr;
714715

715716
/* Drain all packets off the queue */
716717
while (STAILQ_FIRST(&g_ble_ll_data.ll_tx_pkt_q)) {
@@ -719,7 +720,9 @@ ble_ll_tx_pkt_in(void)
719720
om = (struct os_mbuf *)((uint8_t *)pkthdr - sizeof(struct os_mbuf));
720721

721722
/* Remove from queue */
723+
OS_ENTER_CRITICAL(sr);
722724
STAILQ_REMOVE_HEAD(&g_ble_ll_data.ll_tx_pkt_q, omp_next);
725+
OS_EXIT_CRITICAL(sr);
723726

724727
/* Strip HCI ACL header to get handle and length */
725728
handle = get_le16(om->om_data);

0 commit comments

Comments
 (0)