lkml.org 
[lkml]   [2009]   [Aug]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[PATCH -tip] timekeeping: fix getboottime() sets invalid value
From: Hiroshi Shimamoto <h-shimamoto@ct.jp.nec.com>

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>
---
kernel/time/timekeeping.c | 6 ++++--
1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
index 03cbeb3..fb0f46f 100644
--- a/kernel/time/timekeeping.c
+++ b/kernel/time/timekeeping.c
@@ -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);
}

--
1.6.3.3


\
 
 \ /
  Last update: 2009-08-25 08:11    [W:0.216 / U:0.224 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site