x86/cpuidle: replace a pointless NULL check
authorJan Beulich <jbeulich@suse.com>
Thu, 2 Aug 2018 10:12:07 +0000 (12:12 +0200)
committerJan Beulich <jbeulich@suse.com>
Thu, 2 Aug 2018 10:12:07 +0000 (12:12 +0200)
The address of an array slot can't be NULL. Instead add a bounds check
to make sure the array indexing is valid (the check is against 2 since
slot zero of the array - corresponding to C0 - is of no interest here).

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
xen/arch/x86/acpi/cpu_idle.c

index f26d6943622b713086568a81742534419e3cb820..14b02789c54a8038ed4d0c2bf4005725fbc6e5eb 100644 (file)
@@ -759,11 +759,11 @@ void acpi_dead_idle(void)
     struct acpi_processor_power *power;
     struct acpi_processor_cx *cx;
 
-    if ( (power = processor_powers[smp_processor_id()]) == NULL )
+    if ( (power = processor_powers[smp_processor_id()]) == NULL ||
+         power->count < 2 )
         goto default_halt;
 
-    if ( (cx = &power->states[power->count-1]) == NULL )
-        goto default_halt;
+    cx = &power->states[power->count - 1];
 
     if ( cx->entry_method == ACPI_CSTATE_EM_FFH )
     {