Skip to contentSkip to conversation

Uninitialized use of cmd.val in arch/i386/kernel/cpu/cpufreq/acpi-cpufreq.c:423

PATCH New Guillaume Chazarain 2 participants 3 messages Jan 2, 2007

lore
Share & tools
lore
#0 lore raw

Hi,

In arch/i386/kernel/cpu/cpufreq/acpi-cpufreq.c:acpi_cpufreq_target() cmd.val = (cmd.val & ~INTEL_MSR_RANGE) | msr;

cmd.val seems to be used uninitialized. So, one of the attached patch should be needed. Both patches, and no patch at all, work for me though.

This is linux-2.6.20-rc3 and the code is really executed (I traced it) with my Pentium M.

Thanks.

Signature · 1 line
Guillaume
arch/i386/kernel/cpu/cpufreq/acpi-cpufreq.c +1 -3
diff -r 90710ed1291f arch/i386/kernel/cpu/cpufreq/acpi-cpufreq.c
@@ -372,7 +372,6 @@ static int acpi_cpufreq_target(struct cp
 	struct cpufreq_freqs freqs;
 	cpumask_t online_policy_cpus;
 	struct drv_cmd cmd;
-	unsigned int msr;
 	unsigned int next_state = 0;
 	unsigned int next_perf_state = 0;
 	unsigned int i;
@@ -417,10 +416,9 @@ static int acpi_cpufreq_target(struct cp
 	case SYSTEM_INTEL_MSR_CAPABLE:
 		cmd.type = SYSTEM_INTEL_MSR_CAPABLE;
 		cmd.addr.msr.reg = MSR_IA32_PERF_CTL;
-		msr =
+		cmd.val =
 		    (u32) perf->states[next_perf_state].
 		    control & INTEL_MSR_RANGE;
-		cmd.val = (cmd.val & ~INTEL_MSR_RANGE) | msr;
 		break;
 	case SYSTEM_IO_CAPABLE:
 		cmd.type = SYSTEM_IO_CAPABLE;
arch/i386/kernel/cpu/cpufreq/acpi-cpufreq.c +1 -0
diff -r 90710ed1291f arch/i386/kernel/cpu/cpufreq/acpi-cpufreq.c
@@ -420,6 +420,7 @@ static int acpi_cpufreq_target(struct cp
 		msr =
 		    (u32) perf->states[next_perf_state].
 		    control & INTEL_MSR_RANGE;
+		cmd.val = get_cur_val(online_policy_cpus);
 		cmd.val = (cmd.val & ~INTEL_MSR_RANGE) | msr;
 		break;
 	case SYSTEM_IO_CAPABLE:

_______________________________________________
Cpufreq mailing list
[email protected]
http://lists.linux.org.uk/mailman/listinfo/cpufreq

#1 lore raw

RE: Uninitialized use of cmd.val inarch/i386/kernel/cpu/cpufreq/acpi-cpufreq.c:423

Thanks for the patch! This was indeed a bug in the driver.. Acking the second patch acpi_cpufreq_uninitialized_cmd_val2 patch.

Can you please resend with description of the bug and Signed off line and copy Dave so that he can pick up this patch.

Thanks,
Venki

Quoted 28 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Guillaume Chazarain
Sent: Tuesday, January 02, 2007 7:49 AM
To: [email protected]
Subject: Uninitialized use of cmd.val inarch/i386/kernel/cpu/cpufreq/acpi-cpufreq.c:423

Hi,

In arch/i386/kernel/cpu/cpufreq/acpi-cpufreq.c:acpi_cpufreq_target() cmd.val = (cmd.val & ~INTEL_MSR_RANGE) | msr;

cmd.val seems to be used uninitialized. So, one of the attached patch should be needed. Both patches, and no patch at all, work for me though.

This is linux-2.6.20-rc3 and the code is really executed (I traced it) with
my Pentium M.

Thanks.

Signature · 1 line
Guillaume
#2 lore raw

PATCH 1/1 Uninitialized use of cmd.val in arch/i386/kernel/cpu/cpufreq/acpi-cpufreq.c:acpi_cpufreq_target()

Fix for uninitialized use.

Thanks.

Signature · 1 line
Guillaume

cmd.val was used uninitialized on the line below.

---

arch/i386/kernel/cpu/cpufreq/acpi-cpufreq.c +1 -0
diff -r 90710ed1291f arch/i386/kernel/cpu/cpufreq/acpi-cpufreq.c
@@ -420,6 +420,7 @@ static int acpi_cpufreq_target(struct cp
 		msr =
 		    (u32) perf->states[next_perf_state].
 		    control & INTEL_MSR_RANGE;
+		cmd.val = get_cur_val(online_policy_cpus);
 		cmd.val = (cmd.val & ~INTEL_MSR_RANGE) | msr;
 		break;
 	case SYSTEM_IO_CAPABLE:

_______________________________________________
Cpufreq mailing list
[email protected]
http://lists.linux.org.uk/mailman/listinfo/cpufreq