Commit 3bdd40f3 authored by Viresh Kumar's avatar Viresh Kumar Committed by Lin Yujun
Browse files

cpufreq: exit() callback is optional

stable inclusion
from stable-v5.10.219
commit dfc56ff5ec9904c008e9376d90a6d7e2d2bec4d3
category: bugfix
bugzilla: https://gitee.com/src-openeuler/kernel/issues/IA6SHN
CVE: CVE-2024-38615

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=dfc56ff5ec9904c008e9376d90a6d7e2d2bec4d3



--------------------------------

[ Upstream commit b8f85833c05730d631576008daaa34096bc7f3ce ]

The exit() callback is optional and shouldn't be called without checking
a valid pointer first.

Also, we must clear freq_table pointer even if the exit() callback isn't
present.

Signed-off-by: default avatarViresh Kumar <viresh.kumar@linaro.org>
Fixes: 91a12e91 ("cpufreq: Allow light-weight tear down and bring up of CPUs")
Fixes: f339f354 ("cpufreq: Rearrange locking in cpufreq_remove_dev()")
Reported-by: default avatarLizhe <sensor1010@163.com>
Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
Signed-off-by: default avatarLin Yujun <linyujun809@huawei.com>
parent c4145ebf
Loading
Loading
Loading
Loading
+7 −4
Original line number Diff line number Diff line
@@ -1609,11 +1609,14 @@ static void __cpufreq_offline(unsigned int cpu, struct cpufreq_policy *policy)
	 */
	if (cpufreq_driver->offline) {
		cpufreq_driver->offline(policy);
	} else if (cpufreq_driver->exit) {
		return;
	}

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

	policy->freq_table = NULL;
}
}

static int cpufreq_offline(unsigned int cpu)
{
@@ -1662,7 +1665,7 @@ static void cpufreq_remove_dev(struct device *dev, struct subsys_interface *sif)
	}

	/* We did light-weight exit earlier, do full tear down now */
	if (cpufreq_driver->offline)
	if (cpufreq_driver->offline && cpufreq_driver->exit)
		cpufreq_driver->exit(policy);

	up_write(&policy->rwsem);