You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by an...@apache.org on 2022/06/24 08:26:26 UTC
[mynewt-nimble] branch master updated: nimble/ll: Fix race between aux scan and scan disable
This is an automated email from the ASF dual-hosted git repository.
andk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git
The following commit(s) were added to refs/heads/master by this push:
new 23ac4ee4 nimble/ll: Fix race between aux scan and scan disable
23ac4ee4 is described below
commit 23ac4ee47b8029c639c65953aa42e9558c7815d4
Author: Andrzej Kaczmarek <an...@codecoup.pl>
AuthorDate: Tue Jun 21 13:50:15 2022 +0200
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.
---
nimble/controller/src/ble_ll_scan.c | 8 ++++----
nimble/controller/src/ble_ll_scan_aux.c | 5 ++++-
2 files changed, 8 insertions(+), 5 deletions(-)
diff --git a/nimble/controller/src/ble_ll_scan.c b/nimble/controller/src/ble_ll_scan.c
index d9d35178..27f1e65a 100644
--- a/nimble/controller/src/ble_ll_scan.c
+++ b/nimble/controller/src/ble_ll_scan.c
@@ -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;
diff --git a/nimble/controller/src/ble_ll_scan_aux.c b/nimble/controller/src/ble_ll_scan_aux.c
index 2eb915d0..2967083b 100644
--- a/nimble/controller/src/ble_ll_scan_aux.c
+++ b/nimble/controller/src/ble_ll_scan_aux.c
@@ -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;
}