Commit be9d73e6 authored by Jorge Lopez's avatar Jorge Lopez Committed by Hans de Goede

platform/x86: hp-wmi: Fix 0x05 error code reported by several WMI calls

Several WMI queries leverage hp_wmi_read_int function to read their
data. hp_wmi_read_int function was corrected in a previous patch.
Now, this function invokes hp_wmi_perform_query with input parameter
of size zero and the output buffer of size 4.

WMI commands calling hp_wmi_perform_query with input buffer size value
of zero are listed below.

HPWMI_DISPLAY_QUERY
HPWMI_HDDTEMP_QUERY
HPWMI_ALS_QUERY
HPWMI_HARDWARE_QUERY
HPWMI_WIRELESS_QUERY
HPWMI_BIOS_QUERY
HPWMI_FEATURE_QUERY
HPWMI_HOTKEY_QUERY
HPWMI_FEATURE2_QUERY
HPWMI_WIRELESS2_QUERY
HPWMI_POSTCODEERROR_QUERY
HPWMI_THERMAL_PROFILE_QUERY
HPWMI_FAN_SPEED_MAX_GET_QUERY

Invoking those WMI commands with an input buffer size greater
than zero will cause error 0x05 to be returned.

All WMI commands executed by the driver were reviewed and changes
were made to ensure the expected input and output buffer size match
the WMI specification.

Changes were validated on a HP ZBook Workstation notebook,
HP EliteBook x360, and HP EliteBook 850 G8.  Additional
validation was included in the test process to ensure no other
commands were incorrectly handled.
Signed-off-by: default avatarJorge Lopez <jorge.lopez2@hp.com>
Link: https://lore.kernel.org/r/20220310210853.28367-4-jorge.lopez2@hp.comReviewed-by: default avatarHans de Goede <hdegoede@redhat.com>
Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
parent 520ee4ea
...@@ -330,7 +330,7 @@ static int hp_wmi_get_fan_speed(int fan) ...@@ -330,7 +330,7 @@ static int hp_wmi_get_fan_speed(int fan)
char fan_data[4] = { fan, 0, 0, 0 }; char fan_data[4] = { fan, 0, 0, 0 };
int ret = hp_wmi_perform_query(HPWMI_FAN_SPEED_GET_QUERY, HPWMI_GM, int ret = hp_wmi_perform_query(HPWMI_FAN_SPEED_GET_QUERY, HPWMI_GM,
&fan_data, sizeof(fan_data), &fan_data, sizeof(char),
sizeof(fan_data)); sizeof(fan_data));
if (ret != 0) if (ret != 0)
...@@ -399,7 +399,7 @@ static int omen_thermal_profile_set(int mode) ...@@ -399,7 +399,7 @@ static int omen_thermal_profile_set(int mode)
return -EINVAL; return -EINVAL;
ret = hp_wmi_perform_query(HPWMI_SET_PERFORMANCE_MODE, HPWMI_GM, ret = hp_wmi_perform_query(HPWMI_SET_PERFORMANCE_MODE, HPWMI_GM,
&buffer, sizeof(buffer), sizeof(buffer)); &buffer, sizeof(buffer), 0);
if (ret) if (ret)
return ret < 0 ? ret : -EINVAL; return ret < 0 ? ret : -EINVAL;
...@@ -436,7 +436,7 @@ static int hp_wmi_fan_speed_max_set(int enabled) ...@@ -436,7 +436,7 @@ static int hp_wmi_fan_speed_max_set(int enabled)
int ret; int ret;
ret = hp_wmi_perform_query(HPWMI_FAN_SPEED_MAX_SET_QUERY, HPWMI_GM, ret = hp_wmi_perform_query(HPWMI_FAN_SPEED_MAX_SET_QUERY, HPWMI_GM,
&enabled, sizeof(enabled), sizeof(enabled)); &enabled, sizeof(enabled), 0);
if (ret) if (ret)
return ret < 0 ? ret : -EINVAL; return ret < 0 ? ret : -EINVAL;
...@@ -449,7 +449,7 @@ static int hp_wmi_fan_speed_max_get(void) ...@@ -449,7 +449,7 @@ static int hp_wmi_fan_speed_max_get(void)
int val = 0, ret; int val = 0, ret;
ret = hp_wmi_perform_query(HPWMI_FAN_SPEED_MAX_GET_QUERY, HPWMI_GM, ret = hp_wmi_perform_query(HPWMI_FAN_SPEED_MAX_GET_QUERY, HPWMI_GM,
&val, sizeof(val), sizeof(val)); &val, 0, sizeof(val));
if (ret) if (ret)
return ret < 0 ? ret : -EINVAL; return ret < 0 ? ret : -EINVAL;
...@@ -461,7 +461,7 @@ static int __init hp_wmi_bios_2008_later(void) ...@@ -461,7 +461,7 @@ static int __init hp_wmi_bios_2008_later(void)
{ {
int state = 0; int state = 0;
int ret = hp_wmi_perform_query(HPWMI_FEATURE_QUERY, HPWMI_READ, &state, int ret = hp_wmi_perform_query(HPWMI_FEATURE_QUERY, HPWMI_READ, &state,
sizeof(state), sizeof(state)); 0, sizeof(state));
if (!ret) if (!ret)
return 1; return 1;
...@@ -472,7 +472,7 @@ static int __init hp_wmi_bios_2009_later(void) ...@@ -472,7 +472,7 @@ static int __init hp_wmi_bios_2009_later(void)
{ {
u8 state[128]; u8 state[128];
int ret = hp_wmi_perform_query(HPWMI_FEATURE2_QUERY, HPWMI_READ, &state, int ret = hp_wmi_perform_query(HPWMI_FEATURE2_QUERY, HPWMI_READ, &state,
sizeof(state), sizeof(state)); 0, sizeof(state));
if (!ret) if (!ret)
return 1; return 1;
...@@ -550,7 +550,7 @@ static int hp_wmi_rfkill2_refresh(void) ...@@ -550,7 +550,7 @@ static int hp_wmi_rfkill2_refresh(void)
int err, i; int err, i;
err = hp_wmi_perform_query(HPWMI_WIRELESS2_QUERY, HPWMI_READ, &state, err = hp_wmi_perform_query(HPWMI_WIRELESS2_QUERY, HPWMI_READ, &state,
sizeof(state), sizeof(state)); 0, sizeof(state));
if (err) if (err)
return err; return err;
...@@ -639,7 +639,7 @@ static ssize_t als_store(struct device *dev, struct device_attribute *attr, ...@@ -639,7 +639,7 @@ static ssize_t als_store(struct device *dev, struct device_attribute *attr,
return ret; return ret;
ret = hp_wmi_perform_query(HPWMI_ALS_QUERY, HPWMI_WRITE, &tmp, ret = hp_wmi_perform_query(HPWMI_ALS_QUERY, HPWMI_WRITE, &tmp,
sizeof(tmp), sizeof(tmp)); sizeof(tmp), 0);
if (ret) if (ret)
return ret < 0 ? ret : -EINVAL; return ret < 0 ? ret : -EINVAL;
...@@ -660,9 +660,9 @@ static ssize_t postcode_store(struct device *dev, struct device_attribute *attr, ...@@ -660,9 +660,9 @@ static ssize_t postcode_store(struct device *dev, struct device_attribute *attr,
if (clear == false) if (clear == false)
return -EINVAL; return -EINVAL;
/* Clear the POST error code. It is kept until until cleared. */ /* Clear the POST error code. It is kept until cleared. */
ret = hp_wmi_perform_query(HPWMI_POSTCODEERROR_QUERY, HPWMI_WRITE, &tmp, ret = hp_wmi_perform_query(HPWMI_POSTCODEERROR_QUERY, HPWMI_WRITE, &tmp,
sizeof(tmp), sizeof(tmp)); sizeof(tmp), 0);
if (ret) if (ret)
return ret < 0 ? ret : -EINVAL; return ret < 0 ? ret : -EINVAL;
...@@ -952,7 +952,7 @@ static int __init hp_wmi_rfkill2_setup(struct platform_device *device) ...@@ -952,7 +952,7 @@ static int __init hp_wmi_rfkill2_setup(struct platform_device *device)
int err, i; int err, i;
err = hp_wmi_perform_query(HPWMI_WIRELESS2_QUERY, HPWMI_READ, &state, err = hp_wmi_perform_query(HPWMI_WIRELESS2_QUERY, HPWMI_READ, &state,
sizeof(state), sizeof(state)); 0, sizeof(state));
if (err) if (err)
return err < 0 ? err : -EINVAL; return err < 0 ? err : -EINVAL;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment