diff --git a/subsys/bluetooth/controller/ll_sw/ull_scan_aux.c b/subsys/bluetooth/controller/ll_sw/ull_scan_aux.c index a360edde51..db12ddea07 100644 --- a/subsys/bluetooth/controller/ll_sw/ull_scan_aux.c +++ b/subsys/bluetooth/controller/ll_sw/ull_scan_aux.c @@ -163,6 +163,7 @@ void ull_scan_aux_setup(memq_link_t *link, struct node_rx_hdr *rx) /* aux parent will be NULL for periodic sync */ lll = aux->parent; + LL_ASSERT(lll); } else if (!IS_ENABLED(CONFIG_BT_CTLR_SYNC_PERIODIC) || ull_scan_is_valid_get(HDR_LLL2ULL(ftr->param))) { @@ -190,6 +191,7 @@ void ull_scan_aux_setup(memq_link_t *link, struct node_rx_hdr *rx) lll_aux = sync_lll->lll_aux; aux = HDR_LLL2ULL(lll_aux); + LL_ASSERT(sync_lll == aux->parent); } if (!IS_ENABLED(CONFIG_BT_CTLR_SYNC_PERIODIC) || lll) { @@ -756,8 +758,12 @@ void ull_scan_aux_done(struct node_rx_event_done *done) aux = HDR_LLL2ULL(sync->lll.lll_aux); } else { struct ll_scan_set *scan; + struct lll_scan *lll; - scan = HDR_LLL2ULL(aux->parent); + lll = aux->parent; + LL_ASSERT(lll); + + scan = HDR_LLL2ULL(lll); LL_ASSERT(ull_scan_is_valid_get(scan)); /* Auxiliary context will be flushed by ull_scan_aux_stop() */ @@ -800,12 +806,17 @@ void *ull_scan_aux_lll_parent_get(struct lll_scan_aux *lll, uint8_t *is_lll_scan) { struct ll_scan_aux_set *aux; - struct ll_scan_set *scan; aux = HDR_LLL2ULL(lll); - scan = HDR_LLL2ULL(aux->parent); if (is_lll_scan) { + struct ll_scan_set *scan; + struct lll_scan *lll; + + lll = aux->parent; + LL_ASSERT(lll); + + scan = HDR_LLL2ULL(lll); *is_lll_scan = !!ull_scan_is_valid_get(scan); } @@ -884,6 +895,8 @@ void ull_scan_aux_release(memq_link_t *link, struct node_rx_hdr *rx) aux = HDR_LLL2ULL(lll_aux); lll = aux->parent; + LL_ASSERT(lll); + scan = HDR_LLL2ULL(lll); scan = ull_scan_is_valid_get(scan); if (scan) { @@ -975,6 +988,8 @@ int ull_scan_aux_stop(struct ll_scan_aux_set *aux) struct lll_scan *lll; lll = aux->parent; + LL_ASSERT(lll); + scan = HDR_LLL2ULL(lll); scan = ull_scan_is_valid_get(scan); if (scan) { @@ -1016,14 +1031,10 @@ static inline struct ll_scan_aux_set *aux_acquire(void) static inline void aux_release(struct ll_scan_aux_set *aux) { - /* Debug check that parent was assigned when allocated for reception of - * auxiliary channel PDUs. - */ - LL_ASSERT(aux->parent); - /* Clear the parent so that when scan is being disabled then this * auxiliary context shall not associate itself from being disable. */ + LL_ASSERT(aux->parent); aux->parent = NULL; mem_release(aux, &scan_aux_free); @@ -1067,7 +1078,12 @@ static void flush(void *param) struct lll_scan *lll; bool sched = false; + /* Debug check that parent was assigned when allocated for reception of + * auxiliary channel PDUs. + */ aux = param; + LL_ASSERT(aux->parent); + rx = aux->rx_head; if (rx) { ll_rx_put(rx->link, rx); @@ -1143,6 +1159,7 @@ static void aux_sync_incomplete(void *param) /* get reference to sync context */ lll = aux->parent; + LL_ASSERT(lll); sync = HDR_LLL2ULL(lll); /* reset data len total */ @@ -1169,6 +1186,8 @@ static void aux_sync_incomplete(void *param) aux->rx_head = rx; } + LL_ASSERT(!ull_ref_get(&aux->ull)); + flush(aux); #endif /* CONFIG_BT_CTLR_SYNC_PERIODIC */ } @@ -1219,6 +1238,8 @@ static void ticker_op_cb(uint32_t status, void *param) aux = param; sync_lll = aux->parent; + LL_ASSERT(sync_lll); + sync = HDR_LLL2ULL(sync_lll); sync = ull_sync_is_valid_get(sync); } else {