diff options
-rw-r--r-- | drivers/cpufreq/cpufreq.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index 34999fc3216f..cf016584b4ac 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c | |||
@@ -694,8 +694,13 @@ static ssize_t store(struct kobject *kobj, struct attribute *attr, | |||
694 | struct freq_attr *fattr = to_attr(attr); | 694 | struct freq_attr *fattr = to_attr(attr); |
695 | ssize_t ret = -EINVAL; | 695 | ssize_t ret = -EINVAL; |
696 | 696 | ||
697 | get_online_cpus(); | ||
698 | |||
699 | if (!cpu_online(policy->cpu)) | ||
700 | goto unlock; | ||
701 | |||
697 | if (!down_read_trylock(&cpufreq_rwsem)) | 702 | if (!down_read_trylock(&cpufreq_rwsem)) |
698 | goto exit; | 703 | goto unlock; |
699 | 704 | ||
700 | if (lock_policy_rwsem_write(policy->cpu) < 0) | 705 | if (lock_policy_rwsem_write(policy->cpu) < 0) |
701 | goto up_read; | 706 | goto up_read; |
@@ -709,7 +714,9 @@ static ssize_t store(struct kobject *kobj, struct attribute *attr, | |||
709 | 714 | ||
710 | up_read: | 715 | up_read: |
711 | up_read(&cpufreq_rwsem); | 716 | up_read(&cpufreq_rwsem); |
712 | exit: | 717 | unlock: |
718 | put_online_cpus(); | ||
719 | |||
713 | return ret; | 720 | return ret; |
714 | } | 721 | } |
715 | 722 | ||