[xen staging] x86/cpuidle: replace a pointless NULL check

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[xen staging] x86/cpuidle: replace a pointless NULL check

patchbot
commit 68465944c81fa2fbc40bf29ec6084072af5e48ec
Author:     Jan Beulich <[hidden email]>
AuthorDate: Thu Aug 2 12:12:07 2018 +0200
Commit:     Jan Beulich <[hidden email]>
CommitDate: Thu Aug 2 12:12:07 2018 +0200

    x86/cpuidle: replace a pointless NULL check
   
    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 <[hidden email]>
    Acked-by: Andrew Cooper <[hidden email]>
---
 xen/arch/x86/acpi/cpu_idle.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/xen/arch/x86/acpi/cpu_idle.c b/xen/arch/x86/acpi/cpu_idle.c
index f26d694362..14b02789c5 100644
--- a/xen/arch/x86/acpi/cpu_idle.c
+++ b/xen/arch/x86/acpi/cpu_idle.c
@@ -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 )
     {
--
generated by git-patchbot for /home/xen/git/xen.git#staging

_______________________________________________
Xen-changelog mailing list
[hidden email]
https://lists.xenproject.org/xen-changelog