mirror of
https://github.com/torvalds/linux.git
synced 2026-11-07 06:17:02 +01:00
cpufreq/amd-pstate: Restore previous EPP if profile_name allocation fails
amd_pstate_set_dynamic_epp() first applies the EPP value derived from
the current platform profile via amd_pstate_set_epp() and only then
allocates the profile name and registers the platform profile handler
and the power supply notifier. All failures after the EPP has been
programmed jump to the cleanup label, which restores the previously
programmed EPP value.
However, if the kasprintf() of the profile name fails, the function
returns -ENOMEM directly, bypassing the cleanup label, so the EPP value
programmed above is never rolled back even though enabling dynamic EPP
has failed.
Make the allocation failure path jump to the cleanup label as well, so
that the previous EPP value is restored consistently on all error
paths.
Fixes: b7294b6275 ("cpufreq/amd-pstate: Add dynamic EPP as an "energy_performance_preference" mode")
Signed-off-by: Xueqin Luo <luoxueqin@kylinos.cn>
Link: https://lore.kernel.org/r/20260825131400.1509428-1-luoxueqin@kylinos.cn
Signed-off-by: Mario Limonciello <superm1@kernel.org>
This commit is contained in:
parent
c8663e0457
commit
50fb9e04c9
|
|
@ -1381,8 +1381,10 @@ static int amd_pstate_set_dynamic_epp(struct cpufreq_policy *policy)
|
|||
return ret;
|
||||
|
||||
cpudata->profile_name = kasprintf(GFP_KERNEL, "amd-pstate-epp-cpu%d", cpudata->cpu);
|
||||
if (!cpudata->profile_name)
|
||||
return -ENOMEM;
|
||||
if (!cpudata->profile_name) {
|
||||
ret = -ENOMEM;
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
cpudata->ppdev = platform_profile_register(get_cpu_device(policy->cpu),
|
||||
cpudata->profile_name,
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user