platform/x86: hp-wmi: handle positive BIOS error codes
PATCH 1/1 platform/x86: hp-wmi: handle positive BIOS error codes
hp_wmi_perform_query() returns firmware BIOS error codes as positive values. The Victus-S profile callers only reject negative errors, then consume output fields that are not filled for a positive firmware error.
Treat every nonzero result from victus_s_gpu_thermal_profile_get() as a failed query before using its outputs.
--- drivers/platform/x86/hp/hp-wmi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/platform/x86/hp/hp-wmi.c +2 -2
@@ -1825,7 +1825,7 @@ static int victus_s_gpu_thermal_profile_set(bool ctgp_enable, ¤t_ppab_state, ¤t_dstate, ¤t_gpu_slowdown_temp); -if (ret <0 ) { +if (ret) {pr_warn ("GPU modes not updated, unable to get slowdown temp\n" );return ret; }
@@ -1907,7 +1907,7 @@ static int platform_profile_victus_s_get_ec(enum platform_profile_option *profil ¤t_ppab_state, ¤t_dstate, ¤t_gpu_slowdown_temp); -if (ret <0 ) +if (ret)return ret;if (current_ctgp_state ==0 && current_ppab_state ==0 ) *profile =PLATFORM_PROFILE_LOW_POWER ;
Signature · 1 line
2.54.0
Ilpo Järvinen
maintainerQuoted 3 lines · Yousef Alhouseen
hp_wmi_perform_query()returns firmware BIOS error codes as positive values. The Victus-S profile callers only reject negative errors, then consume output fields that are not filled for a positive firmware error.
On which hw you see this? Please add the info.
Quoted 31 lines
Treat every nonzero result from
victus_s_gpu_thermal_profile_get()as a failed query before using its outputs.Signed-off-by Yousef Alhouseen <[email protected]>--- drivers/platform/x86/hp/hp-wmi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/platform/x86/hp/hp-wmi.c +2
-2@@ -1825,7 +1825,7 @@ static int victus_s_gpu_thermal_profile_set(bool ctgp_enable, ¤t_ppab_state, ¤t_dstate, ¤t_gpu_slowdown_temp); -if (ret <0 ) { +if (ret) {pr_warn ("GPU modes not updated, unable to get slowdown temp\n" );return ret; }@@ -1907,7 +1907,7 @@ static int platform_profile_victus_s_get_ec(enum platform_profile_option *profil ¤t_ppab_state, ¤t_dstate, ¤t_gpu_slowdown_temp); -if (ret <0 ) +if (ret)return ret;if (current_ctgp_state ==0 && current_ppab_state ==0 ) *profile =PLATFORM_PROFILE_LOW_POWER ;
Signature · 1 line
i.
Hi Ilpo,
No specific hardware exhibited this; I found it by static inspection. hp_wmi_perform_query() documents positive BIOS error returns, while victus_s_gpu_thermal_profile_get() only initializes its output arguments when the return is zero, so these two ret < 0 checks can consume uninitialized values on a positive return.
I only ran strict checkpatch and a focused Clang build of hp-wmi.o. I do not have a Victus S system to reproduce it. If hardware validation is required for this change, I am happy to withdraw it.
Regards,
Yousef
Quoted 42 lines · Ilpo Järvinen
Quoted 3 lines · Yousef Alhouseen
hp_wmi_perform_query()returns firmware BIOS error codes as positive values. The Victus-S profile callers only reject negative errors, then consume output fields that are not filled for a positive firmware error.On which hw you see this? Please add the info.
Quoted 23 lines
Treat every nonzero result from
victus_s_gpu_thermal_profile_get()as a failed query before using its outputs.Signed-off-by Yousef Alhouseen <[email protected]>---
drivers/platform/x86/hp/hp-wmi.c| 4 ++--1 file changed, 2 insertions(+), 2 deletions(-)drivers/platform/x86/hp/hp-wmi.c +1
-1@@ -1825,7 +1825,7 @@ static int victus_s_gpu_thermal_profile_set(bool ctgp_enable, ¤t_ppab_state, ¤t_dstate, ¤t_gpu_slowdown_temp); -if (ret <0 ) { +if (ret) {pr_warn ("GPU modes not updated, unable to get slowdown temp\n" );return ret; }drivers/platform/x86/hp/hp-wmi.c static int platform_profile_victus_s_get_ec(enum platform_profile_option *profil · line 1913
Quoted 8 lines
drivers/platform/x86/hp/hp-wmi.c +1
-1@@ -1907,7 +1907,7 @@ static int platform_profile_victus_s_get_ec(enum platform_profile_option *profil ¤t_ppab_state, ¤t_dstate, ¤t_gpu_slowdown_temp); -if (ret <0 ) +if (ret)return ret;if (current_ctgp_state ==0 && current_ppab_state ==0 ) *profile =PLATFORM_PROFILE_LOW_POWER ;--
i.