Skip to content

Commit

Permalink
timekeeping: Fix invalid getboottime() value
Browse files Browse the repository at this point in the history
Don't use timespec_add_safe() with wall_to_monotonic, because
wall_to_monotonic has negative values which will cause overflow
in timespec_add_safe(). That makes btime in /proc/stat invalid.

Signed-off-by: Hiroshi Shimamoto <h-shimamoto@ct.jp.nec.com>
Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
Cc: John Stultz <johnstul@us.ibm.com>
Cc: Daniel Walker <dwalker@fifo99.com>
LKML-Reference: <4A937FDE.4050506@ct.jp.nec.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
  • Loading branch information
Hiroshi Shimamoto authored and Ingo Molnar committed Aug 25, 2009
1 parent 0ceb4c3 commit 36d4748
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions kernel/time/timekeeping.c
Original file line number Diff line number Diff line change
Expand Up @@ -826,9 +826,11 @@ void update_wall_time(void)
*/
void getboottime(struct timespec *ts)
{
struct timespec boottime;
struct timespec boottime = {
.tv_sec = wall_to_monotonic.tv_sec + total_sleep_time.tv_sec,
.tv_nsec = wall_to_monotonic.tv_nsec + total_sleep_time.tv_nsec
};

boottime = timespec_add_safe(wall_to_monotonic, total_sleep_time);
set_normalized_timespec(ts, -boottime.tv_sec, -boottime.tv_nsec);
}

Expand Down

0 comments on commit 36d4748

Please sign in to comment.