Bluetooth: Controller: Fix auxiliary scan stop assertion check
Use a local variable to assert check on auxiliary context's
release.
Add missing volatile qualifier to the parent field of the
auxiliary scan context.
Under race condition a released aux context can be allocated
for reception of chain PDU of a periodic sync role, hence
fix the assertion check to consider that the released
context can be allocated to other roles.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
diff --git a/subsys/bluetooth/controller/ll_sw/ull_scan.c b/subsys/bluetooth/controller/ll_sw/ull_scan.c
index b28a707..64ac7c0 100644
--- a/subsys/bluetooth/controller/ll_sw/ull_scan.c
+++ b/subsys/bluetooth/controller/ll_sw/ull_scan.c
@@ -639,12 +639,21 @@
aux_scan = HDR_LLL2ULL(aux_scan_lll);
if (aux_scan == scan) {
+ void *parent;
+
err = ull_scan_aux_stop(aux);
if (err && (err != -EALREADY)) {
return BT_HCI_ERR_CMD_DISALLOWED;
}
- LL_ASSERT(!aux->parent);
+ /* Use a local variable to assert on auxiliary context's
+ * release.
+ * Under race condition a released aux context can be
+ * allocated for reception of chain PDU of a periodic
+ * sync role.
+ */
+ parent = aux->parent;
+ LL_ASSERT(!parent || (parent != aux_scan_lll));
}
}
#endif /* CONFIG_BT_CTLR_ADV_EXT */
diff --git a/subsys/bluetooth/controller/ll_sw/ull_scan_types.h b/subsys/bluetooth/controller/ll_sw/ull_scan_types.h
index 969f6fa..d10ef58 100644
--- a/subsys/bluetooth/controller/ll_sw/ull_scan_types.h
+++ b/subsys/bluetooth/controller/ll_sw/ull_scan_types.h
@@ -43,7 +43,7 @@
struct lll_scan_aux lll;
/* lll_scan or lll_sync */
- void *parent;
+ void *volatile parent;
struct node_rx_hdr *rx_head;
struct node_rx_hdr *rx_last;