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

Commit 575464db authored by Joonwoo Park's avatar Joonwoo Park Committed by Gerrit - the friendly Code Review server
Browse files

sched: prevent out of bound access in sched_group_energy()



group_idle_state() can return INT_MAX + 1 which is undefined behaviour
when there is no CPUs in sched_group.  Prevent such by error correctly.

Change-Id: I236a90b9725edc2f394ade6533368f5d4b1a21d2
Signed-off-by: default avatarJoonwoo Park <joonwoop@codeaurora.org>
Signed-off-by: default avatarSatya Durga Srinivasu Prabhala <satyap@codeaurora.org>
parent dc0a96e6
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -5765,6 +5765,9 @@ static int group_idle_state(struct energy_env *eenv, int cpu_idx)
	for_each_cpu(i, sched_group_span(sg))
		state = min(state, idle_get_state_idx(cpu_rq(i)));

	if (unlikely(state == INT_MAX))
		return -EINVAL;

	/* Take non-cpuidle idling into account (active idle/arch_cpu_idle()) */
	state++;
	/*