timekeeping: Prevent oops when GENERIC_TIME=n
authorjohn stultz <johnstul@us.ibm.com>
Mon, 1 Mar 2010 20:34:43 +0000 (12:34 -0800)
committerThomas Gleixner <tglx@linutronix.de>
Tue, 2 Mar 2010 08:22:25 +0000 (09:22 +0100)
Aaro Koskinen reported an issue in kernel.org bugzilla #15366, where
on non-GENERIC_TIME systems, accessing
/sys/devices/system/clocksource/clocksource0/current_clocksource
results in an oops.

It seems the timekeeper/clocksource rework missed initializing the
curr_clocksource value in the !GENERIC_TIME case.

Thanks to Aaro for reporting and diagnosing the issue as well as
testing the fix!

Reported-by: Aaro Koskinen <aaro.koskinen@iki.fi>
Signed-off-by: John Stultz <johnstul@us.ibm.com>
Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
Cc: stable@kernel.org
LKML-Reference: <1267475683.4216.61.camel@localhost.localdomain>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
kernel/time/clocksource.c

index 1f663d23e85e940d71716627d2de509143a88bfb..1f5dde637457e94e8a5bcdcda498044bbb9844c1 100644 (file)
@@ -592,6 +592,10 @@ static inline void clocksource_select(void) { }
  */
 static int __init clocksource_done_booting(void)
 {
+       mutex_lock(&clocksource_mutex);
+       curr_clocksource = clocksource_default_clock();
+       mutex_unlock(&clocksource_mutex);
+
        finished_booting = 1;
 
        /*