Skip to content

Commit

Permalink
cpufreq: check cpufreq driver is valid and cpufreq isn't disabled in …
Browse files Browse the repository at this point in the history
…cpufreq_get()

cpufreq_get() can be called from external drivers which might not be aware if
cpufreq driver is registered or not. And so we should actually check if cpufreq
driver is registered or not and also if cpufreq is active or disabled, at the
beginning of cpufreq_get().

Otherwise call to lock_policy_rwsem_read() might hit BUG_ON(!policy).

Reported-and-tested-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Srivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
  • Loading branch information
Viresh Kumar authored and Rafael J. Wysocki committed Sep 25, 2013
1 parent 8a61e12 commit 26ca869
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions drivers/cpufreq/cpufreq.c
Original file line number Diff line number Diff line change
Expand Up @@ -1460,6 +1460,9 @@ unsigned int cpufreq_get(unsigned int cpu)
{
unsigned int ret_freq = 0;

if (cpufreq_disabled() || !cpufreq_driver)
return -ENOENT;

if (!down_read_trylock(&cpufreq_rwsem))
return 0;

Expand Down

0 comments on commit 26ca869

Please sign in to comment.