fishy code in arch/x86/kernel/tsc.c:time_cpufreq_notifier()

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Christoph Hellwig
Date: Monday, June 1, 2009 - 7:21 am

Just notice the following error from gcc 4.4:

arch/x86/kernel/tsc.c: In function 'time_cpufreq_notifier':
arch/x86/kernel/tsc.c:634: warning: 'dummy' may be used uninitialized in this function

dummy is only used in the following way in this function:

	lpj = &dummy;

and then dummy might be overriden in the following odd way:

	if (!(freq->flags & CPUFREQ_CONST_LOOPS))
#ifdef CONFIG_SMP
		lpj = &cpu_data(freq->cpu).loops_per_jiffy;
#else
	lpj = &boot_cpu_data.loops_per_jiffy;
#endif

and then is used in

	if (!ref_freq) {
		ref_freq = freq->old;
		loops_per_jiffy_ref = *lpj;
		tsc_khz_ref = tsc_khz;
	}

to me that looks like it can indeed be used unitialized for the case
where we do have CONFIG_SMP set, freq->flags & CPUFREQ_CONST_LOOPS is
true and ref_freq is false.

Can that case actually happen?
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
fishy code in arch/x86/kernel/tsc.c:time_cpufreq_notifier(), Christoph Hellwig, (Mon Jun 1, 7:21 am)