Bluetooth: Controller: Add development assert to check auxiliary parent

Add development assert to check the validity of auxiliary
context's parent. This is to ensure a released auxiliary
context is not reused without allocation.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
This commit is contained in:
Vinayak Kariappa Chettimada 2021-12-23 11:43:58 +05:30 committed by Carles Cufí
parent ebe64beb2a
commit 18ca682357

View file

@ -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 {