Skip to content

Commit be9d73e

Browse files
Jorge Lopezjwrdegoede
authored andcommitted
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: Jorge Lopez <[email protected]> Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Hans de Goede <[email protected]> Signed-off-by: Hans de Goede <[email protected]>
1 parent 520ee4e commit be9d73e

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

drivers/platform/x86/hp-wmi.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ static int hp_wmi_get_fan_speed(int fan)
330330
char fan_data[4] = { fan, 0, 0, 0 };
331331

332332
int ret = hp_wmi_perform_query(HPWMI_FAN_SPEED_GET_QUERY, HPWMI_GM,
333-
&fan_data, sizeof(fan_data),
333+
&fan_data, sizeof(char),
334334
sizeof(fan_data));
335335

336336
if (ret != 0)
@@ -399,7 +399,7 @@ static int omen_thermal_profile_set(int mode)
399399
return -EINVAL;
400400

401401
ret = hp_wmi_perform_query(HPWMI_SET_PERFORMANCE_MODE, HPWMI_GM,
402-
&buffer, sizeof(buffer), sizeof(buffer));
402+
&buffer, sizeof(buffer), 0);
403403

404404
if (ret)
405405
return ret < 0 ? ret : -EINVAL;
@@ -436,7 +436,7 @@ static int hp_wmi_fan_speed_max_set(int enabled)
436436
int ret;
437437

438438
ret = hp_wmi_perform_query(HPWMI_FAN_SPEED_MAX_SET_QUERY, HPWMI_GM,
439-
&enabled, sizeof(enabled), sizeof(enabled));
439+
&enabled, sizeof(enabled), 0);
440440

441441
if (ret)
442442
return ret < 0 ? ret : -EINVAL;
@@ -449,7 +449,7 @@ static int hp_wmi_fan_speed_max_get(void)
449449
int val = 0, ret;
450450

451451
ret = hp_wmi_perform_query(HPWMI_FAN_SPEED_MAX_GET_QUERY, HPWMI_GM,
452-
&val, sizeof(val), sizeof(val));
452+
&val, 0, sizeof(val));
453453

454454
if (ret)
455455
return ret < 0 ? ret : -EINVAL;
@@ -461,7 +461,7 @@ static int __init hp_wmi_bios_2008_later(void)
461461
{
462462
int state = 0;
463463
int ret = hp_wmi_perform_query(HPWMI_FEATURE_QUERY, HPWMI_READ, &state,
464-
sizeof(state), sizeof(state));
464+
0, sizeof(state));
465465
if (!ret)
466466
return 1;
467467

@@ -472,7 +472,7 @@ static int __init hp_wmi_bios_2009_later(void)
472472
{
473473
u8 state[128];
474474
int ret = hp_wmi_perform_query(HPWMI_FEATURE2_QUERY, HPWMI_READ, &state,
475-
sizeof(state), sizeof(state));
475+
0, sizeof(state));
476476
if (!ret)
477477
return 1;
478478

@@ -550,7 +550,7 @@ static int hp_wmi_rfkill2_refresh(void)
550550
int err, i;
551551

552552
err = hp_wmi_perform_query(HPWMI_WIRELESS2_QUERY, HPWMI_READ, &state,
553-
sizeof(state), sizeof(state));
553+
0, sizeof(state));
554554
if (err)
555555
return err;
556556

@@ -639,7 +639,7 @@ static ssize_t als_store(struct device *dev, struct device_attribute *attr,
639639
return ret;
640640

641641
ret = hp_wmi_perform_query(HPWMI_ALS_QUERY, HPWMI_WRITE, &tmp,
642-
sizeof(tmp), sizeof(tmp));
642+
sizeof(tmp), 0);
643643
if (ret)
644644
return ret < 0 ? ret : -EINVAL;
645645

@@ -660,9 +660,9 @@ static ssize_t postcode_store(struct device *dev, struct device_attribute *attr,
660660
if (clear == false)
661661
return -EINVAL;
662662

663-
/* Clear the POST error code. It is kept until until cleared. */
663+
/* Clear the POST error code. It is kept until cleared. */
664664
ret = hp_wmi_perform_query(HPWMI_POSTCODEERROR_QUERY, HPWMI_WRITE, &tmp,
665-
sizeof(tmp), sizeof(tmp));
665+
sizeof(tmp), 0);
666666
if (ret)
667667
return ret < 0 ? ret : -EINVAL;
668668

@@ -952,7 +952,7 @@ static int __init hp_wmi_rfkill2_setup(struct platform_device *device)
952952
int err, i;
953953

954954
err = hp_wmi_perform_query(HPWMI_WIRELESS2_QUERY, HPWMI_READ, &state,
955-
sizeof(state), sizeof(state));
955+
0, sizeof(state));
956956
if (err)
957957
return err < 0 ? err : -EINVAL;
958958

0 commit comments

Comments
 (0)