Skip to content

Commit c1d5adb

Browse files
Saravana Kannanhyperb1iss
authored andcommitted
cpufreq: Fix policy getting stuck when user & kernel min/max don't overlap
Every __cpufreq_set_policy starts with checking the new policy min/max has some overlap with the current policy min/max. This works out fine until we end up with the policy min/max being set to a range that doesn't overlap with the user policy min/max. Once we get into this situation, the check at the start of __cpufreq_set_policy fails and prevents us from getting out of this state. This only happens when one of the CPUFREQ_ADJUST/CPUFREQ_INCOMPATIBLE notifiers called inside __cpufreq_set_policy pick a min/max outside the range of user policy min/max. The real intent of the check at the start of __cpufreq_set_policy is to make sure userspace can't set user policy min > user policy max. Since __cpufreq_set_policy always gets called only with current user policy min/max except when the actual user space policy min/max is changed, we can fix the issue by simply checking the new policy min/max against current user policy min/max. Change-Id: Iaac805825e64d7985c41fb9052bd96baacdf3d6f Signed-off-by: Saravana Kannan <skannan@codeaurora.org>
1 parent c8458e3 commit c1d5adb

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

drivers/cpufreq/cpufreq.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1751,7 +1751,8 @@ static int __cpufreq_set_policy(struct cpufreq_policy *data,
17511751
memcpy(&policy->cpuinfo, &data->cpuinfo,
17521752
sizeof(struct cpufreq_cpuinfo));
17531753

1754-
if (policy->min > data->max || policy->max < data->min) {
1754+
if (policy->min > data->user_policy.max
1755+
|| policy->max < data->user_policy.min) {
17551756
ret = -EINVAL;
17561757
goto error_out;
17571758
}

0 commit comments

Comments
 (0)