Commit 87d2a8de authored by K Prateek Nayak's avatar K Prateek Nayak Committed by Mario Limonciello (AMD)
Browse files

cpufreq/amd-pstate: Return -ENOMEM on failure to allocate profile_name



Failure to allocate profile name will return -EINVAL from
platform_profile_register() while in fact, it is a failure to allocate
memory for the profile_name string.

Return -ENOMEM when kasprintf() fails to allocate profile_name string.

Fixes: e30ca6dd ("cpufreq/amd-pstate: Add dynamic energy performance preference")
Reviewed-by: default avatarMario Limonciello <mario.limonciello@amd.com>
Signed-off-by: default avatarK Prateek Nayak <kprateek.nayak@amd.com>
Link: https://lore.kernel.org/r/20260508051748.10484-3-kprateek.nayak@amd.com


Signed-off-by: default avatarMario Limonciello (AMD) <superm1@kernel.org>
parent 9228169d
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -1291,6 +1291,8 @@ 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;

	cpudata->ppdev = platform_profile_register(get_cpu_device(policy->cpu),
						   cpudata->profile_name,