Skip to content

Commit 9d56385

Browse files
ljd42nordicjm
authored andcommitted
[nrf fromtree] Bluetooth: Controller: fix assertion check for ptc value
Fix the issue reported by Coverity CID 487708. The LL_ASSERT was performed on lll->ptc, which is a 4-bit bitfield and therefore always succeeds. Instead, the computation (lll->nse - nse) should be checked to ensure it falls within the 4-bit value range before assigning it to lll->ptc. Signed-off-by: Loic Domaigne <[email protected]> (cherry picked from commit bfbc636) Signed-off-by: Vinayak Kariappa Chettimada <[email protected]>
1 parent 4199556 commit 9d56385

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

subsys/bluetooth/controller/ll_sw/ull_sync_iso.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -489,20 +489,22 @@ void ull_sync_iso_setup(struct ll_sync_iso_set *sync_iso,
489489
lll->irc = PDU_BIG_INFO_IRC_GET(bi);
490490
if (lll->pto) {
491491
uint8_t nse;
492+
uint8_t ptc;
492493

493494
nse = lll->irc * lll->bn; /* 4 bits * 3 bits, total 7 bits */
494495
if (nse >= lll->nse) {
495496
return;
496497
}
497498

498-
lll->ptc = lll->nse - nse;
499+
ptc = lll->nse - nse;
499500

500501
/* FIXME: Do not remember why ptc is 4 bits, it should be 5 bits as ptc is a
501502
* running buffer offset related to nse.
502503
* Fix ptc and ptc_curr definitions, until then we keep an assertion check
503504
* here.
504505
*/
505-
LL_ASSERT(lll->ptc <= BIT_MASK(4));
506+
LL_ASSERT(ptc <= BIT_MASK(4));
507+
lll->ptc = ptc;
506508
} else {
507509
lll->ptc = 0U;
508510
}

0 commit comments

Comments
 (0)