Skip to contentSkip to conversation

intel_idle: Fix uninitialized variable bug

PATCH In review Dan Carpenter 2 participants 4 messages Jun 24, 2020 – Jun 25, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 intel_idle: Fix uninitialized variable bug

The "tick" variable isn't initialized if "lapic_timer_always_reliable" is true.

Fixes 40ab82e08d78 ("intel_idle: Simplify LAPIC timer reliability checks")
---
 drivers/idle/intel_idle.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/idle/intel_idle.c +1 -1
index aae53e650638..6c9152f303a6 100644
@@ -132,7 +132,7 @@ static __cpuidle int intel_idle(struct cpuidle_device *dev,
 	struct cpuidle_state *state = &drv->states[index];
 	unsigned long eax = flg2MWAIT(state->flags);
 	unsigned long ecx = 1; /* break on interrupt flag */
-	bool tick;
+	bool tick = false;
 	int cpu = smp_processor_id();
 
 	/*
Signature · 1 line
2.27.0
#1 lore raw
Quoted 3 lines · Dan Carpenter

The "tick" variable isn't initialized if "lapic_timer_always_reliable" is true.

If lapic_timer_always_reliable is true, then static_cpu_has(X86_FEATURE_ARAT) must also be true AFAICS.

So the lapic_timer_always_reliable check in there looks redundant.

Quoted 20 lines
Fixes 40ab82e08d78 ("intel_idle: Simplify LAPIC timer reliability checks")
---
 drivers/idle/intel_idle.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/idle/intel_idle.c +1 -2
index aae53e650638..6c9152f303a6 100644
@@ -132,7 +132,7 @@ static __cpuidle int intel_idle(struct cpuidle_device *dev,
        struct cpuidle_state *state = &drv->states[index];
        unsigned long eax = flg2MWAIT(state->flags);
        unsigned long ecx = 1; /* break on interrupt flag */
-       bool tick;
+       bool tick = false;
        int cpu = smp_processor_id();
 
        /*
--
#2 lore raw
Quoted 9 lines · Rafael J. Wysocki
Quoted 3 lines · Dan Carpenter

The "tick" variable isn't initialized if "lapic_timer_always_reliable" is true.

If lapic_timer_always_reliable is true, then static_cpu_has(X86_FEATURE_ARAT) must also be true AFAICS.

So the lapic_timer_always_reliable check in there looks redundant.

Can the lapic_timer_always_reliable variable just be removed entirely and replaced with an static_cpu_has(X86_FEATURE_ARAT) check?

regards,
dan carpenter

#3 lore raw
Quoted 7 lines · Dan Carpenter
Quoted 5 lines · Rafael J. Wysocki
Quoted 3 lines · Dan Carpenter

The "tick" variable isn't initialized if "lapic_timer_always_reliable" is true.

Quoted 7 lines
Quoted 4 lines

If lapic_timer_always_reliable is true, then static_cpu_has(X86_FEATURE_ARAT) must also be true AFAICS.

So the lapic_timer_always_reliable check in there looks redundant.

Can the lapic_timer_always_reliable variable just be removed entirely and replaced with an static_cpu_has(X86_FEATURE_ARAT) check?

Yes, it can.

See https://patchwork.kernel.org/patch/11623309/

Thanks!