Skip to content

Commit

Permalink
Revert "cpufreq: Fix possible race in cpufreq online error path"
Browse files Browse the repository at this point in the history
[ Upstream commit 85f0e42 ]

This reverts commit f346e96.

The commit tried to fix a possible real bug but it made it even worse.
The fix was simply buggy as now an error out to out_offline_policy or
out_exit_policy will try to release a semaphore which was never taken in
the first place. This works fine only if we failed late, i.e. via
out_destroy_policy.

Fixes: f346e96 ("cpufreq: Fix possible race in cpufreq online error path")
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
vireshk authored and gregkh committed Jun 9, 2022
1 parent 10f5372 commit ca3fd5f
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions drivers/cpufreq/cpufreq.c
Expand Up @@ -1528,6 +1528,8 @@ static int cpufreq_online(unsigned int cpu)
for_each_cpu(j, policy->real_cpus)
remove_cpu_dev_symlink(policy, get_cpu_device(j));

up_write(&policy->rwsem);

out_offline_policy:
if (cpufreq_driver->offline)
cpufreq_driver->offline(policy);
Expand All @@ -1536,9 +1538,6 @@ static int cpufreq_online(unsigned int cpu)
if (cpufreq_driver->exit)
cpufreq_driver->exit(policy);

cpumask_clear(policy->cpus);
up_write(&policy->rwsem);

out_free_policy:
cpufreq_policy_free(policy);
return ret;
Expand Down

0 comments on commit ca3fd5f

Please sign in to comment.