Unverified Commit 45442e92 authored by openeuler-ci-bot's avatar openeuler-ci-bot Committed by Gitee
Browse files

!2781 cpufreq: Abort show()/store() for half-initialized policies

Merge Pull Request from: @ci-robot 
 
PR sync from: Jinjie Ruan <ruanjinjie@huawei.com>
https://mailweb.openeuler.org/hyperkitty/list/kernel@openeuler.org/message/O35IHGH2KCUVQEY2DUY4XHXCW5HOZEDK/ 
Fix cpu offline but cat scaling_cur_freq is the same as online bug.

Changes in v2:
- Fix the CHECKPATCH warnings.

Schspa Shi (2):
  cpufreq: Abort show()/store() for half-initialized policies
  cpufreq: make interface functions and lock holding state clear


-- 
2.34.1
 
https://gitee.com/openeuler/kernel/issues/I8EI9L 
 
Link:https://gitee.com/openeuler/kernel/pulls/2781

 

Reviewed-by: default avatarZhang Jianhua <chris.zjh@huawei.com>
Reviewed-by: default avatarLiu YongQiang <liuyongqiang13@huawei.com>
Signed-off-by: default avatarZhang Changzhong <zhangchangzhong@huawei.com>
parents bb08feaf 8ce1fbb8
Loading
Loading
Loading
Loading
+10 −8
Original line number Diff line number Diff line
@@ -907,12 +907,13 @@ static ssize_t show(struct kobject *kobj, struct attribute *attr, char *buf)
{
	struct cpufreq_policy *policy = to_policy(kobj);
	struct freq_attr *fattr = to_attr(attr);
	ssize_t ret;
	ssize_t ret = -EBUSY;

	if (!fattr->show)
		return -EIO;

	down_read(&policy->rwsem);
	if (likely(!policy_is_inactive(policy)))
		ret = fattr->show(policy, buf);
	up_read(&policy->rwsem);

@@ -924,7 +925,7 @@ static ssize_t store(struct kobject *kobj, struct attribute *attr,
{
	struct cpufreq_policy *policy = to_policy(kobj);
	struct freq_attr *fattr = to_attr(attr);
	ssize_t ret = -EINVAL;
	ssize_t ret = -EBUSY;

	if (!fattr->store)
		return -EIO;
@@ -938,6 +939,7 @@ static ssize_t store(struct kobject *kobj, struct attribute *attr,

	if (cpu_online(policy->cpu)) {
		down_write(&policy->rwsem);
		if (likely(!policy_is_inactive(policy)))
			ret = fattr->store(policy, buf, count);
		up_write(&policy->rwsem);
	}
@@ -1198,12 +1200,12 @@ static int cpufreq_online(unsigned int cpu)
		down_write(&policy->rwsem);
		policy->cpu = cpu;
		policy->governor = NULL;
		up_write(&policy->rwsem);
	} else {
		new_policy = true;
		policy = cpufreq_policy_alloc(cpu);
		if (!policy)
			return -ENOMEM;
		down_write(&policy->rwsem);
	}

	cpumask_copy(policy->cpus, cpumask_of(cpu));
@@ -1221,8 +1223,6 @@ static int cpufreq_online(unsigned int cpu)
	if (ret)
		goto out_exit_policy;

	down_write(&policy->rwsem);

	if (new_policy) {
		/* related_cpus should at least include policy->cpus. */
		cpumask_copy(policy->related_cpus, policy->cpus);
@@ -1332,13 +1332,15 @@ 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);
	cpumask_clear(policy->cpus);

out_exit_policy:
	if (cpufreq_driver->exit)
		cpufreq_driver->exit(policy);

out_free_policy:
	up_write(&policy->rwsem);

	cpufreq_policy_free(policy);
	return ret;
}