Skip to content

Commit 1bbe209

Browse files
cvinayakfabiobaltieri
authored andcommitted
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 <[email protected]>
1 parent 6d67a81 commit 1bbe209

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

subsys/bluetooth/controller/ll_sw/ull_scan.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -639,12 +639,21 @@ uint8_t ull_scan_disable(uint8_t handle, struct ll_scan_set *scan)
639639

640640
aux_scan = HDR_LLL2ULL(aux_scan_lll);
641641
if (aux_scan == scan) {
642+
void *parent;
643+
642644
err = ull_scan_aux_stop(aux);
643645
if (err && (err != -EALREADY)) {
644646
return BT_HCI_ERR_CMD_DISALLOWED;
645647
}
646648

647-
LL_ASSERT(!aux->parent);
649+
/* Use a local variable to assert on auxiliary context's
650+
* release.
651+
* Under race condition a released aux context can be
652+
* allocated for reception of chain PDU of a periodic
653+
* sync role.
654+
*/
655+
parent = aux->parent;
656+
LL_ASSERT(!parent || (parent != aux_scan_lll));
648657
}
649658
}
650659
#endif /* CONFIG_BT_CTLR_ADV_EXT */

subsys/bluetooth/controller/ll_sw/ull_scan_types.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ struct ll_scan_aux_set {
4343
struct lll_scan_aux lll;
4444

4545
/* lll_scan or lll_sync */
46-
void *parent;
46+
void *volatile parent;
4747

4848
struct node_rx_hdr *rx_head;
4949
struct node_rx_hdr *rx_last;

0 commit comments

Comments
 (0)