lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date:	Wed, 20 May 2009 11:51:15 +0530
From:	Subrata Modak <subrata@...ux.vnet.ibm.com>
To:	<x86@...nel.org>
Cc:	Sachin P Sant <sachinp@...ux.vnet.ibm.com>,
	"H. Peter Anvin" <hpa@...or.com>, Frans Pop <elendil@...net.nl>,
	Andi Kleen <andi@...stfloor.org>,
	Thomas Gleixner <tglx@...utronix.de>,
	Linux Kernel <linux-kernel@...r.kernel.org>,
	Ingo Molnar <mingo@...hat.com>,
	Subrata Modak <subrata@...ux.vnet.ibm.com>,
	Balbir Singh <balbir@...ux.vnet.ibm.com>
Subject: [PATCH][Resend] Remove indirect variable usage at arch/x86/kernel/tsc.c

Hi,

The following warning is generated on compilation:

CC      arch/x86/kernel/tsc.o
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

However, there seems to be no practical usage of variable 'dummy'
in the following piece of code:

630 static int time_cpufreq_notifier(struct notifier_block *nb, unsigned long val,
631                                 void *data)
632 {
633         struct cpufreq_freqs *freq = data;
634         unsigned long *lpj, dummy;
635 
636         if (cpu_has(&cpu_data(freq->cpu), X86_FEATURE_CONSTANT_TSC))
637                 return 0;
638 
639         lpj = &dummy;
640         if (!(freq->flags & CPUFREQ_CONST_LOOPS))
641 #ifdef CONFIG_SMP
642                 lpj = &cpu_data(freq->cpu).loops_per_jiffy;
643 #else
644         lpj = &boot_cpu_data.loops_per_jiffy;
645 #endif
646 

'lpj' probably will get to point to some address after this if() statement.

647         if (!ref_freq) {
648                 ref_freq = freq->old;
649                 loops_per_jiffy_ref = *lpj;

And, if it does, then "loops_per_jiffy_ref" will have a proper value,
else, even with "lpj = &dummy" will not gurantee "loops_per_jiffy_ref = *lpj"
to have the expected value.

650                 tsc_khz_ref = tsc_khz;
651         }
652         if ((val == CPUFREQ_PRECHANGE  && freq->old < freq->new) ||
653                         (val == CPUFREQ_POSTCHANGE && freq->old > freq->new) ||
654                         (val == CPUFREQ_RESUMECHANGE)) {
655                 *lpj =  cpufreq_scale(loops_per_jiffy_ref, ref_freq, freq->new);
656 
657                 tsc_khz = cpufreq_scale(tsc_khz_ref, ref_freq, freq->new);
658                 if (!(freq->flags & CPUFREQ_CONST_LOOPS))
659                         mark_tsc_unstable("cpufreq changes");
660         }
661 
662         set_cyc2ns_scale(tsc_khz, freq->cpu);
663 
664         return 0;
665 }

Is there any specific reason for 'dummy' to exist in this function ?
If not, i would like to propose the following fix. Also included fix expected
by Frans Pop:

> No comments on your patch, but it might be good to also fix the incorrect 
> indentation here: line 644 needs an extra tab.

Please refer:
http://lkml.org/lkml/2009/5/19/312, and,
http://lkml.org/lkml/2009/5/19/301.

Signed-off-by: Subrata Modak <subrata@...ux.vnet.ibm.com>
To: <x86@...nel.org>
Cc: H. Peter Anvin <hpa@...or.com>
Cc: Ingo Molnar <mingo@...hat.com>
Cc: Thomas Gleixner <tglx@...utronix.de>
Cc: Balbir Singh <balbir@...ux.vnet.ibm.com>
Cc: Sachin P Sant <sachinp@...ux.vnet.ibm.com>
Cc: Linux Kernel <linux-kernel@...r.kernel.org>
Cc: Andi Kleen <andi@...stfloor.org>
Cc: Frans Pop <elendil@...net.nl>
Subject: [PATCH][Resend] Remove indirect variable usage at arch/x86/kernel/tsc.c
---

--- a/arch/x86/kernel/tsc.c	2009-05-20 10:29:23.000000000 +0530
+++ b/arch/x86/kernel/tsc.c	2009-05-20 11:42:53.000000000 +0530
@@ -631,17 +631,16 @@ static int time_cpufreq_notifier(struct 
 				void *data)
 {
 	struct cpufreq_freqs *freq = data;
-	unsigned long *lpj, dummy;
+	unsigned long *lpj = NULL;
 
 	if (cpu_has(&cpu_data(freq->cpu), X86_FEATURE_CONSTANT_TSC))
 		return 0;
 
-	lpj = &dummy;
 	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;
+		lpj = &boot_cpu_data.loops_per_jiffy;
 #endif
 
 	if (!ref_freq) {

---
Regards--
Subrata

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists