diff options
| author | Jacob Shin <jacob.shin@amd.com> | 2013-06-25 16:42:37 -0400 |
|---|---|---|
| committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2013-06-25 16:42:37 -0400 |
| commit | c28375583b6471c1cb833a628ab6afb5b69079d0 (patch) | |
| tree | 80255430a54c44c57a39d88cc2d7d030a4b0d8b6 /drivers/cpufreq | |
| parent | 9e895ace5d82df8929b16f58e9f515f6d54ab82d (diff) | |
cpufreq: fix NULL pointer deference at od_set_powersave_bias()
When initializing the default powersave_bias value, we need to first
make sure that this policy is running the ondemand governor.
Reported-and-tested-by: Tim Gardner <tim.gardner@canonical.com>
Signed-off-by: Jacob Shin <jacob.shin@amd.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'drivers/cpufreq')
| -rw-r--r-- | drivers/cpufreq/cpufreq_ondemand.c | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/drivers/cpufreq/cpufreq_ondemand.c b/drivers/cpufreq/cpufreq_ondemand.c index 4b9bb5def6f1..93eb5cbcc1f6 100644 --- a/drivers/cpufreq/cpufreq_ondemand.c +++ b/drivers/cpufreq/cpufreq_ondemand.c | |||
| @@ -47,6 +47,8 @@ static struct od_ops od_ops; | |||
| 47 | static struct cpufreq_governor cpufreq_gov_ondemand; | 47 | static struct cpufreq_governor cpufreq_gov_ondemand; |
| 48 | #endif | 48 | #endif |
| 49 | 49 | ||
| 50 | static unsigned int default_powersave_bias; | ||
| 51 | |||
| 50 | static void ondemand_powersave_bias_init_cpu(int cpu) | 52 | static void ondemand_powersave_bias_init_cpu(int cpu) |
| 51 | { | 53 | { |
| 52 | struct od_cpu_dbs_info_s *dbs_info = &per_cpu(od_cpu_dbs_info, cpu); | 54 | struct od_cpu_dbs_info_s *dbs_info = &per_cpu(od_cpu_dbs_info, cpu); |
| @@ -543,7 +545,7 @@ static int od_init(struct dbs_data *dbs_data) | |||
| 543 | 545 | ||
| 544 | tuners->sampling_down_factor = DEF_SAMPLING_DOWN_FACTOR; | 546 | tuners->sampling_down_factor = DEF_SAMPLING_DOWN_FACTOR; |
| 545 | tuners->ignore_nice = 0; | 547 | tuners->ignore_nice = 0; |
| 546 | tuners->powersave_bias = 0; | 548 | tuners->powersave_bias = default_powersave_bias; |
| 547 | tuners->io_is_busy = should_io_be_busy(); | 549 | tuners->io_is_busy = should_io_be_busy(); |
| 548 | 550 | ||
| 549 | dbs_data->tuners = tuners; | 551 | dbs_data->tuners = tuners; |
| @@ -585,6 +587,7 @@ static void od_set_powersave_bias(unsigned int powersave_bias) | |||
| 585 | unsigned int cpu; | 587 | unsigned int cpu; |
| 586 | cpumask_t done; | 588 | cpumask_t done; |
| 587 | 589 | ||
| 590 | default_powersave_bias = powersave_bias; | ||
| 588 | cpumask_clear(&done); | 591 | cpumask_clear(&done); |
| 589 | 592 | ||
| 590 | get_online_cpus(); | 593 | get_online_cpus(); |
| @@ -593,11 +596,17 @@ static void od_set_powersave_bias(unsigned int powersave_bias) | |||
| 593 | continue; | 596 | continue; |
| 594 | 597 | ||
| 595 | policy = per_cpu(od_cpu_dbs_info, cpu).cdbs.cur_policy; | 598 | policy = per_cpu(od_cpu_dbs_info, cpu).cdbs.cur_policy; |
| 596 | dbs_data = policy->governor_data; | 599 | if (!policy) |
| 597 | od_tuners = dbs_data->tuners; | 600 | continue; |
| 598 | od_tuners->powersave_bias = powersave_bias; | ||
| 599 | 601 | ||
| 600 | cpumask_or(&done, &done, policy->cpus); | 602 | cpumask_or(&done, &done, policy->cpus); |
| 603 | |||
| 604 | if (policy->governor != &cpufreq_gov_ondemand) | ||
| 605 | continue; | ||
| 606 | |||
| 607 | dbs_data = policy->governor_data; | ||
| 608 | od_tuners = dbs_data->tuners; | ||
| 609 | od_tuners->powersave_bias = default_powersave_bias; | ||
| 601 | } | 610 | } |
| 602 | put_online_cpus(); | 611 | put_online_cpus(); |
| 603 | } | 612 | } |
