Skip to content

Commit 3590bd6

Browse files
cvinayakfabiobaltieri
authored andcommitted
Bluetooth: Controller: Fix missing invalid aux offset check
Fix missing invalid aux offset check that was being caught in a development assertion check. If aux offset where less than the PDU time of the primary channel PDU, radio was redundantly being setup delayed for reception that was being caught in an assertion check. Signed-off-by: Vinayak Kariappa Chettimada <[email protected]>
1 parent 521ea55 commit 3590bd6

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

subsys/bluetooth/controller/ll_sw/nordic/lll/lll_scan_aux.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ uint8_t lll_scan_aux_setup(struct pdu_adv *pdu, uint8_t pdu_phy,
129129
uint32_t aux_offset_us;
130130
uint32_t overhead_us;
131131
uint8_t *pri_dptr;
132+
uint32_t pdu_us;
132133
uint8_t phy;
133134

134135
LL_ASSERT(pdu->type == PDU_ADV_TYPE_EXT_IND);
@@ -183,6 +184,12 @@ uint8_t lll_scan_aux_setup(struct pdu_adv *pdu, uint8_t pdu_phy,
183184
/* Calculate the aux offset from start of the scan window */
184185
aux_offset_us = (uint32_t)PDU_ADV_AUX_PTR_OFFSET_GET(aux_ptr) * window_size_us;
185186

187+
/* Skip reception if invalid aux offset */
188+
pdu_us = PDU_AC_US(pdu->len, pdu_phy, pdu_phy_flags_rx);
189+
if (aux_offset_us < pdu_us) {
190+
return 0U;
191+
}
192+
186193
/* Calculate the window widening that needs to be deducted */
187194
if (aux_ptr->ca) {
188195
window_widening_us = SCA_DRIFT_50_PPM_US(aux_offset_us);
@@ -233,7 +240,7 @@ uint8_t lll_scan_aux_setup(struct pdu_adv *pdu, uint8_t pdu_phy,
233240
ftr->radio_end_us = radio_tmr_end_get() -
234241
radio_rx_chain_delay_get(pdu_phy,
235242
pdu_phy_flags_rx) -
236-
PDU_AC_US(pdu->len, pdu_phy, pdu_phy_flags_rx);
243+
pdu_us;
237244

238245
radio_isr_set(setup_cb, node_rx);
239246
radio_disable();

subsys/bluetooth/controller/ll_sw/ull_scan_aux.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ void ull_scan_aux_setup(memq_link_t *link, struct node_rx_pdu *rx)
126126
uint8_t acad_len;
127127
uint8_t data_len;
128128
uint8_t hdr_len;
129+
uint32_t pdu_us;
129130
uint8_t *ptr;
130131
uint8_t phy;
131132

@@ -705,6 +706,12 @@ void ull_scan_aux_setup(memq_link_t *link, struct node_rx_pdu *rx)
705706

706707
aux_offset_us = (uint32_t)PDU_ADV_AUX_PTR_OFFSET_GET(aux_ptr) * lll_aux->window_size_us;
707708

709+
/* Skip reception if invalid aux offset */
710+
pdu_us = PDU_AC_US(pdu->len, phy, ftr->phy_flags);
711+
if (aux_offset_us < pdu_us) {
712+
goto ull_scan_aux_rx_flush;
713+
}
714+
708715
/* CA field contains the clock accuracy of the advertiser;
709716
* 0 - 51 ppm to 500 ppm
710717
* 1 - 0 ppm to 50 ppm
@@ -723,7 +730,7 @@ void ull_scan_aux_setup(memq_link_t *link, struct node_rx_pdu *rx)
723730

724731
/* Calculate the aux offset from start of the scan window */
725732
aux_offset_us += ftr->radio_end_us;
726-
aux_offset_us -= PDU_AC_US(pdu->len, phy, ftr->phy_flags);
733+
aux_offset_us -= pdu_us;
727734
aux_offset_us -= EVENT_TICKER_RES_MARGIN_US;
728735
aux_offset_us -= EVENT_JITTER_US;
729736
aux_offset_us -= ready_delay_us;

0 commit comments

Comments
 (0)