]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
cpufreq/amd-pstate: Return -ENOMEM on failure to allocate profile_name
authorK Prateek Nayak <kprateek.nayak@amd.com>
Fri, 8 May 2026 05:17:44 +0000 (05:17 +0000)
committerMario Limonciello (AMD) <superm1@kernel.org>
Fri, 8 May 2026 05:30:50 +0000 (00:30 -0500)
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: e30ca6dd5345 ("cpufreq/amd-pstate: Add dynamic energy performance preference")
Reviewed-by: Mario Limonciello <mario.limonciello@amd.com>
Signed-off-by: K Prateek Nayak <kprateek.nayak@amd.com>
Link: https://lore.kernel.org/r/20260508051748.10484-3-kprateek.nayak@amd.com
Signed-off-by: Mario Limonciello (AMD) <superm1@kernel.org>
drivers/cpufreq/amd-pstate.c

index 5e2d28c73294d61b6d51836f61b50b1319174952..72514be2f30fb9a7675e0aa0d6716f6c69fc4287 100644 (file)
@@ -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,