===================================================================
@@ -862,13 +862,11 @@ static ssize_t show(struct kobject *kobj
struct freq_attr *fattr = to_attr(attr);
ssize_t ret;
- down_read(&policy->rwsem);
-
- if (fattr->show)
- ret = fattr->show(policy, buf);
- else
- ret = -EIO;
+ if (WARN_ON(!fattr->show))
+ return -EIO;
+ down_read(&policy->rwsem);
+ ret = fattr->show(policy, buf);
up_read(&policy->rwsem);
return ret;
@@ -881,20 +879,17 @@ static ssize_t store(struct kobject *kob
struct freq_attr *fattr = to_attr(attr);
ssize_t ret = -EINVAL;
- get_online_cpus();
-
- if (!cpu_online(policy->cpu))
- goto unlock;
+ if (WARN_ON(!fattr->store))
+ return -EIO;
- down_write(&policy->rwsem);
+ get_online_cpus();
- if (fattr->store)
+ if (cpu_online(policy->cpu)) {
+ down_write(&policy->rwsem);
ret = fattr->store(policy, buf, count);
- else
- ret = -EIO;
+ up_write(&policy->rwsem);
+ }
- up_write(&policy->rwsem);
-unlock:
put_online_cpus();
return ret;