Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a802ea96 authored by Rafael J. Wysocki's avatar Rafael J. Wysocki
Browse files

cpuidle: Check the sign of index in cpuidle_reflect()



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: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
Reviewed-by: default avatarDaniel Lezcano <daniel.lezcano@linaro.org>
Acked-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
parent 82f66327
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -249,7 +249,7 @@ int cpuidle_enter(struct cpuidle_driver *drv, struct cpuidle_device *dev,
 */
 */
void cpuidle_reflect(struct cpuidle_device *dev, int index)
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);
		cpuidle_curr_governor->reflect(dev, index);
}
}


+2 −2
Original line number Original line Diff line number Diff line
@@ -367,8 +367,8 @@ static int menu_select(struct cpuidle_driver *drv, struct cpuidle_device *dev)
static void menu_reflect(struct cpuidle_device *dev, int index)
static void menu_reflect(struct cpuidle_device *dev, int index)
{
{
	struct menu_device *data = this_cpu_ptr(&menu_devices);
	struct menu_device *data = this_cpu_ptr(&menu_devices);

	data->last_state_idx = index;
	data->last_state_idx = index;
	if (index >= 0)
	data->needs_update = 1;
	data->needs_update = 1;
}
}