Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 961137a0 authored by Andre Eisenbach's avatar Andre Eisenbach
Browse files

Fix integer overflow in GKI timer calculation

Fix an integer overflow in the GKI timer elapsed time calculation that
would cause Bluetooth Stereo Audio (A2DP) playback to stop suddenly
after a period of INT32_MAX microseconds (about 35 minutes) of
continuous uptime of the phone/tablet.

Bug: 16412377
Change-Id: I28cd3155a23444e41b26b3f3b8424cc2a3c5bf91
parent 79da68c1
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -114,7 +114,7 @@ static UINT64 now_us()
{
    struct timespec ts_now;
    clock_gettime(CLOCK_BOOTTIME, &ts_now);
    return (ts_now.tv_sec * USEC_PER_SEC) + (ts_now.tv_nsec / NSEC_PER_USEC);
    return ((UINT64)ts_now.tv_sec * USEC_PER_SEC) + ((UINT64)ts_now.tv_nsec / NSEC_PER_USEC);
}

static bool set_nonwake_alarm(UINT64 delay_millis)
+1 −1
Original line number Diff line number Diff line
@@ -368,7 +368,7 @@ static UINT64 time_now_us()
{
    struct timespec ts_now;
    clock_gettime(CLOCK_BOOTTIME, &ts_now);
    return (ts_now.tv_sec * USEC_PER_SEC) + (ts_now.tv_nsec / 1000);
    return ((UINT64)ts_now.tv_sec * USEC_PER_SEC) + ((UINT64)ts_now.tv_nsec / 1000);
}

static void log_tstamps_us(char *comment)