]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
cpuidle: Check the sign of index in cpuidle_reflect()
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>
Mon, 4 May 2015 20:53:28 +0000 (22:53 +0200)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Mon, 4 May 2015 20:53:28 +0000 (22:53 +0200)
Avoid calling the governor's ->reflect method if the state index
passed to cpuidle_reflect() is negative.

This allows the analogous check to be dropped from menu_reflect(),
so do that too, and ensures that arbitrary error codes can be
passed to cpuidle_reflect() as the index with no adverse
consequences.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Reviewed-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
drivers/cpuidle/cpuidle.c
drivers/cpuidle/governors/menu.c

index 61c417b9e53f8795175b29d71dfd201f15be151c..3b80b77a585d5f66b57da05e27caa1c9feb8e8bc 100644 (file)
@@ -249,7 +249,7 @@ int cpuidle_enter(struct cpuidle_driver *drv, struct cpuidle_device *dev,
  */
 void cpuidle_reflect(struct cpuidle_device *dev, int index)
 {
-       if (cpuidle_curr_governor->reflect)
+       if (cpuidle_curr_governor->reflect && index >= 0)
                cpuidle_curr_governor->reflect(dev, index);
 }
 
index b8a5fa15ca24af1d20928ff4fd22ff36785a2552..22e4463d1787ab3d37aaaa61cfc402c16a315a2d 100644 (file)
@@ -367,9 +367,9 @@ static int menu_select(struct cpuidle_driver *drv, struct cpuidle_device *dev)
 static void menu_reflect(struct cpuidle_device *dev, int index)
 {
        struct menu_device *data = this_cpu_ptr(&menu_devices);
+
        data->last_state_idx = index;
-       if (index >= 0)
-               data->needs_update = 1;
+       data->needs_update = 1;
 }
 
 /**