]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
cpufreq/amd-pstate: Adjust return values in amd_pstate_update_status()
authorMario Limonciello (AMD) <superm1@kernel.org>
Thu, 9 Oct 2025 16:17:54 +0000 (11:17 -0500)
committerMario Limonciello (AMD) <superm1@kernel.org>
Tue, 11 Nov 2025 05:35:20 +0000 (23:35 -0600)
get_mode_idx_from_str() already checks the upper boundary for a string
sent.  Drop the extra check in amd_pstate_update_status() and pass
the return code if there is a failure.

Reviewed-by: Gautham R. Shenoy <gautham.shenoy@amd.com>
Signed-off-by: Mario Limonciello (AMD) <superm1@kernel.org>
drivers/cpufreq/amd-pstate.c

index 5feb9f5e3a49148d784ffd3c2e422ac41a803432..2d2ef53d1244704598131e7166d8ce6a20d41c0c 100644 (file)
@@ -1346,9 +1346,8 @@ int amd_pstate_update_status(const char *buf, size_t size)
                return -EINVAL;
 
        mode_idx = get_mode_idx_from_str(buf, size);
-
-       if (mode_idx < 0 || mode_idx >= AMD_PSTATE_MAX)
-               return -EINVAL;
+       if (mode_idx < 0)
+               return mode_idx;
 
        if (mode_state_machine[cppc_state][mode_idx]) {
                guard(mutex)(&amd_pstate_driver_lock);