nimble/ll: Fix race between aux scan and scan disable

It's possible that scheduled aux is being received while scan sm is
being disabled. In such case aux should not be processed since it cannot
be handled properly anyway.
This commit is contained in:
Andrzej Kaczmarek
2022-06-24 10:26:20 +02:00
parent 16f1e4d7b2
commit 23ac4ee47b
2 changed files with 8 additions and 5 deletions
+4 -4
View File
@@ -880,10 +880,6 @@ ble_ll_scan_sm_stop(int chk_disable)
OS_ENTER_CRITICAL(sr);
#if MYNEWT_VAL(BLE_LL_ROLE_CENTRAL)
scansm->connsm = NULL;
#endif
/* Disable scanning state machine */
scansm->scan_enabled = 0;
scansm->restart_timer_needed = 0;
@@ -895,6 +891,10 @@ ble_ll_scan_sm_stop(int chk_disable)
}
#endif
#if MYNEWT_VAL(BLE_LL_ROLE_CENTRAL)
scansm->connsm = NULL;
#endif
/* Update backoff if we failed to receive scan response */
if (scansm->scan_rsp_pending) {
scansm->scan_rsp_pending = 0;
+4 -1
View File
@@ -1237,7 +1237,10 @@ ble_ll_scan_aux_rx_isr_end(struct os_mbuf *rxpdu, uint8_t crcok)
rxinfo = &rxhdr->rxinfo;
rxinfo->user_data = aux;
if (!crcok) {
/* It's possible that we received aux while scan was just being disabled in
* LL task. In such case simply ignore aux.
*/
if (!crcok || !ble_ll_scan_enabled()) {
rxinfo->flags |= BLE_MBUF_HDR_F_IGNORED;
goto done;
}