Bluetooth: controller: Fix integer overflow in scheduling code

Fix an integer overflow in the scheduling implementation
that calculates whether resources required for next radio
event be retained.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
This commit is contained in:
Vinayak Kariappa Chettimada 2018-11-01 08:05:42 +01:00 committed by Anas Nashif
parent cb53a1a2d5
commit 133d3870b3
1 changed files with 9 additions and 3 deletions

View File

@ -4897,9 +4897,15 @@ static void mayfly_xtal_stop_calc(void *params)
/* Compensate for next ticker in reduced prepare */
if (hdr_next->ticks_xtal_to_start & XON_BITMASK) {
ticks_to_expire -=
(hdr_next->ticks_xtal_to_start &
~XON_BITMASK) - ticks_prepare_to_start_next;
u32_t ticks_reduced = (hdr_next->ticks_xtal_to_start &
~XON_BITMASK) -
ticks_prepare_to_start_next;
if (ticks_to_expire > ticks_reduced) {
ticks_to_expire -= ticks_reduced;
} else {
ticks_to_expire = 0;
}
}
/* If beyond the xtal threshold reset to normal the next prepare,