Skip to content

Commit a87e8dc

Browse files
Tronilkartben
authored andcommitted
Bluetooth: Controller: Fix lost_payloads calculation for FT > 1
The lost_payloads calculation in ull_conn_iso_start() could easily end up negative for CIS with FT > 1; Add a check to avoid this Signed-off-by: Troels Nilsson <[email protected]>
1 parent d56da37 commit a87e8dc

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

subsys/bluetooth/controller/ll_sw/ull_conn_iso.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -977,10 +977,20 @@ void ull_conn_iso_start(struct ll_conn *conn, uint16_t cis_handle,
977977

978978
cis->lll.event_count_prepare += lost_cig_events;
979979

980-
lost_payloads = (lost_cig_events - (cis->lll.rx.ft - 1)) * cis->lll.rx.bn;
980+
if (lost_cig_events > (cis->lll.rx.ft - 1)) {
981+
lost_payloads = (lost_cig_events - (cis->lll.rx.ft - 1)) *
982+
cis->lll.rx.bn;
983+
} else {
984+
lost_payloads = 0U;
985+
}
981986
cis->lll.rx.payload_count += lost_payloads;
982987

983-
lost_payloads = (lost_cig_events - (cis->lll.tx.ft - 1)) * cis->lll.tx.bn;
988+
if (lost_cig_events > (cis->lll.tx.ft - 1)) {
989+
lost_payloads = (lost_cig_events - (cis->lll.tx.ft - 1)) *
990+
cis->lll.tx.bn;
991+
} else {
992+
lost_payloads = 0U;
993+
}
984994
cis->lll.tx.payload_count += lost_payloads;
985995

986996
/* Adjust for extra window widening */

0 commit comments

Comments
 (0)