Fix SW_TABLET_MODE detection method
v4 cover Fix SW_TABLET_MODE detection method
The intension for this patch was to address SW_TABLET_MODE detection problem. It is during the initial investigation; two other issues were identified and are related to the initial task.
First, several WMI queries were reporting error 0x05 including HPWMI_HARDWARE_QUERY that is responsible for returning dock and table modes values. See patch v3 part 2 comments for list of WMI queries affected. The driver now reports the appropriate states and values correctly.
Lastly, a limiting data size restriction was discovered. struct bios_args data member size limits all possible WMI commands to those requiring buffer size of 128 bytes or less. Several WMI commands and queries require a buffer size larger than 128 bytes hence limiting current and new feature supported by the driver. hp_wmi_perform_query function changed to handle the memory allocation and release of any required buffer size.
Jorge Lopez (3):
Fix SW_TABLET_MODE detection method
Fix 0x05 error code reported by several WMI calls Changing bios_args.data to be dynamically allocated
drivers/platform/x86/hp-wmi.c | 161 +++++++++++++++++++++++----------- 1 file changed, 109 insertions(+), 52 deletions(-)
Signature · 1 line
2.25.1
PATCH v4 1/3 Fix SW_TABLET_MODE detection method
The purpose of this patch is to introduce a fix and removal of the current hack when determining tablet mode status.
Determining the tablet mode status requires reading Byte 0 bit 2 as reported by HPWMI_HARDWARE_QUERY. The investigation identified the failure was rooted in two areas: HPWMI_HARDWARE_QUERY failure (0x05) and reading Byte 0, bit 2 only to determine the table mode status. HPWMI_HARDWARE_QUERY WMI failure also rendered the dock state value invalid.
The latest changes use SMBIOS Type 3 (chassis type) and WMI Command 0x40 (device_mode_status) information to determine if the device is in tablet mode or not.
hp_wmi_hw_state function was split into two functions; hp_wmi_get_dock_state and hp_wmi_get_tablet_mode. The new functions separate how dock_state and tablet_mode is handled in a cleaner manner.
All changes were validated on a HP ZBook Workstation notebook, HP EliteBook x360, and HP EliteBook 850 G8.
---
Based on the latest platform-drivers-x86.git/for-next
--- drivers/platform/x86/hp-wmi.c | 80 ++++++++++++++++++++++++++--------- 1 file changed, 60 insertions(+), 20 deletions(-)
drivers/platform/x86/hp-wmi.c +60 -20
@@ -35,10 +35,6 @@ MODULE_LICENSE("GPL");MODULE_ALIAS ("wmi:95F24279-4D7B-4334-9387-ACCDC67EF61C" );MODULE_ALIAS ("wmi:5FB7F034-2C63-45e9-BE91-3D44E2C707E4" ); -static int enable_tablet_mode_sw =-1 ; -module_param (enable_tablet_mode_sw, int,0444 ); -MODULE_PARM_DESC (enable_tablet_mode_sw,"Enable SW_TABLET_MODE reporting (-1=auto, 0=no, 1=yes)" ); -#define HPWMI_EVENT_GUID "95F24279-4D7B-4334-9387-ACCDC67EF61C"#define HPWMI_BIOS_GUID "5FB7F034-2C63-45e9-BE91-3D44E2C707E4"#define HP_OMEN_EC_THERMAL_PROFILE_OFFSET 0x95
@@ -107,6 +103,7 @@ enum hp_wmi_commandtype {HPWMI_FEATURE2_QUERY =0x0d ,HPWMI_WIRELESS2_QUERY =0x1b ,HPWMI_POSTCODEERROR_QUERY =0x2a , +HPWMI_SYSTEM_DEVICE_MODE =0x40 , HPWMI_THERMAL_PROFILE_QUERY = 0x4c, };
@@ -217,6 +214,18 @@ struct rfkill2_device {static int rfkill2_count;static struct rfkill2_device rfkill2[HPWMI_MAX_RFKILL2_DEVICES ]; +/* Chassis Types values were obtained from SMBIOS reference +* specification version 3.00. A complete list of system enclosures +* and chassis types is available on Table 17. +*/ +static const char *const tablet_chassis_types[] = { +"30" ,/* Tablet*/ +"31" ,/* Convertible */ +"32" /* Detachable */ +}; + +#define DEVICE_MODE_TABLET 0x06 +/* map output size to the corresponding WMI method id */ static inline int encode_outsize_for_pvsz (int outsize) {
@@ -337,7 +346,7 @@ static int hp_wmi_read_int(int query)int val =0 , ret; ret =hp_wmi_perform_query (query,HPWMI_READ , &val, -sizeof (val),sizeof (val)); +0 ,sizeof (val));if (ret)return ret <0 ? ret : -EINVAL ;
@@ -345,14 +354,47 @@ static int hp_wmi_read_int(int query)return val; } -static int hp_wmi_hw_state (int mask) +static int hp_wmi_get_dock_state (void ) {int state =hp_wmi_read_int (HPWMI_HARDWARE_QUERY );if (state <0 )return state; -return !!(state & mask); +if (!(state &HPWMI_DOCK_MASK )) +return 0 ; + +return 1 ; +} + +static int hp_wmi_get_tablet_mode (void ) +{ +char system_device_mode[4 ] = {0 }; +int ret; +bool tablet_found = false; + +const char *chassis_type =dmi_get_system_info (DMI_CHASSIS_TYPE ); + +if (!chassis_type) +return 0 ; + + tablet_found =match_string (tablet_chassis_types, +ARRAY_SIZE (tablet_chassis_types), + chassis_type) >=0 ; + +if (!tablet_found) +return 0 ; + + ret =hp_wmi_perform_query (HPWMI_SYSTEM_DEVICE_MODE ,HPWMI_READ , + system_device_mode,0 ,sizeof (system_device_mode)); + +if (ret <0 ) +return 0 ; + +if (system_device_mode[0 ] ==DEVICE_MODE_TABLET ) +return 1 ; + +return 0 ; }static int omen_thermal_profile_set (int mode)
@@ -568,7 +610,7 @@ static ssize_t als_show(struct device *dev, struct device_attribute *attr,static ssize_t dock_show (struct device *dev,struct device_attribute *attr,char *buf) { -int value =hp_wmi_hw_state (HPWMI_DOCK_MASK ); +int value =hp_wmi_get_dock_state ();if (value <0 )return value;return sprintf (buf,"%d\n" , value);
@@ -577,7 +619,7 @@ static ssize_t dock_show(struct device *dev, struct device_attribute *attr,static ssize_t tablet_show (struct device *dev,struct device_attribute *attr,char *buf) { -int value =hp_wmi_hw_state (HPWMI_TABLET_MASK ); +int value =hp_wmi_get_tablet_mode ();if (value <0 )return value;return sprintf (buf,"%d\n" , value);
@@ -699,10 +741,10 @@ static void hp_wmi_notify(u32 value, void *context)case HPWMI_DOCK_EVENT :if (test_bit (SW_DOCK , hp_wmi_input_dev->swbit))input_report_switch (hp_wmi_input_dev,SW_DOCK , -hp_wmi_hw_state (HPWMI_DOCK_MASK )); +hp_wmi_get_dock_state ());if (test_bit (SW_TABLET_MODE , hp_wmi_input_dev->swbit))input_report_switch (hp_wmi_input_dev,SW_TABLET_MODE , -hp_wmi_hw_state (HPWMI_TABLET_MASK )); +hp_wmi_get_tablet_mode ());input_sync (hp_wmi_input_dev);break ;case HPWMI_PARK_HDD :
@@ -780,19 +822,17 @@ static int __init hp_wmi_input_setup(void)__set_bit (EV_SW , hp_wmi_input_dev->evbit);/* Dock */ - val =hp_wmi_hw_state (HPWMI_DOCK_MASK ); + val =hp_wmi_get_dock_state ();if (!(val <0 )) {__set_bit (SW_DOCK , hp_wmi_input_dev->swbit);input_report_switch (hp_wmi_input_dev,SW_DOCK , val); }/* Tablet mode */ -if (enable_tablet_mode_sw >0 ) { - val =hp_wmi_hw_state (HPWMI_TABLET_MASK ); -if (val >=0 ) { -__set_bit (SW_TABLET_MODE , hp_wmi_input_dev->swbit); -input_report_switch (hp_wmi_input_dev,SW_TABLET_MODE , val); - } + val =hp_wmi_get_tablet_mode (); +if (!(val <0 )) { +__set_bit (SW_TABLET_MODE , hp_wmi_input_dev->swbit); +input_report_switch (hp_wmi_input_dev,SW_TABLET_MODE , val); } err =sparse_keymap_setup (hp_wmi_input_dev, hp_wmi_keymap,NULL );
@@ -1227,10 +1267,10 @@ static int hp_wmi_resume_handler(struct device *device)if (hp_wmi_input_dev) {if (test_bit (SW_DOCK , hp_wmi_input_dev->swbit))input_report_switch (hp_wmi_input_dev,SW_DOCK , -hp_wmi_hw_state (HPWMI_DOCK_MASK )); +hp_wmi_get_dock_state ());if (test_bit (SW_TABLET_MODE , hp_wmi_input_dev->swbit))input_report_switch (hp_wmi_input_dev,SW_TABLET_MODE , -hp_wmi_hw_state (HPWMI_TABLET_MASK )); +hp_wmi_get_tablet_mode ());input_sync (hp_wmi_input_dev); }
Signature · 1 line
2.25.1
Hi Jorge,
Quoted 13 lines · Jorge Lopez
The purpose of this patch is to introduce a fix and removal of the current hack when determining tablet mode status.
Determining the tablet mode status requires reading Byte 0 bit 2 as reported by
HPWMI_HARDWARE_QUERY. The investigation identified the failure was rooted in two areas:HPWMI_HARDWARE_QUERYfailure (0x05) and reading Byte 0, bit 2 only to determine the table mode status.HPWMI_HARDWARE_QUERYWMI failure also rendered the dock state value invalid.The latest changes use SMBIOS Type 3 (chassis type) and WMI Command
0x40(device_mode_status) information to determine if the device is in tablet mode or not.
Quoted 8 lines
hp_wmi_hw_statefunction was split into two functions;hp_wmi_get_dock_stateandhp_wmi_get_tablet_mode. The new functions separate howdock_stateandtablet_modeis handled in a cleaner manner.All changes were validated on a HP ZBook Workstation notebook, HP EliteBook x360, and HP EliteBook 850 G8.
Signed-off-by Jorge Lopez <[email protected]>
This is mostly looking good, some small remarks / request for tweaks below. After those I believe that this patch will be ready for merging.
Quoted 50 lines
---
Based on the latest platform-drivers-x86.git/for-next--- drivers/platform/x86/hp-wmi.c | 80 ++++++++++++++++++++++++++--------- 1 file changed, 60 insertions(+), 20 deletions(-)drivers/platform/x86/hp-wmi.c +13
-4@@ -35,10 +35,6 @@ MODULE_LICENSE("GPL");MODULE_ALIAS ("wmi:95F24279-4D7B-4334-9387-ACCDC67EF61C" );MODULE_ALIAS ("wmi:5FB7F034-2C63-45e9-BE91-3D44E2C707E4" ); -static int enable_tablet_mode_sw =-1 ; -module_param (enable_tablet_mode_sw, int,0444 ); -MODULE_PARM_DESC (enable_tablet_mode_sw,"Enable SW_TABLET_MODE reporting (-1=auto, 0=no, 1=yes)" ); -#define HPWMI_EVENT_GUID "95F24279-4D7B-4334-9387-ACCDC67EF61C"#define HPWMI_BIOS_GUID "5FB7F034-2C63-45e9-BE91-3D44E2C707E4"#define HP_OMEN_EC_THERMAL_PROFILE_OFFSET 0x95@@ -107,6 +103,7 @@ enum hp_wmi_commandtype {HPWMI_FEATURE2_QUERY =0x0d ,HPWMI_WIRELESS2_QUERY =0x1b ,HPWMI_POSTCODEERROR_QUERY =0x2a , +HPWMI_SYSTEM_DEVICE_MODE =0x40 , HPWMI_THERMAL_PROFILE_QUERY = 0x4c, };@@ -217,6 +214,18 @@ struct rfkill2_device {static int rfkill2_count;static struct rfkill2_device rfkill2[HPWMI_MAX_RFKILL2_DEVICES ]; +/* Chassis Types values were obtained from SMBIOS reference +* specification version 3.00. A complete list of system enclosures +* and chassis types is available on Table 17. +*/ +static const char *const tablet_chassis_types[] = { +"30" ,/* Tablet*/ +"31" ,/* Convertible */ +"32" /* Detachable */ +}; + +#define DEVICE_MODE_TABLET 0x06 +/* map output size to the corresponding WMI method id */ static inline int encode_outsize_for_pvsz (int outsize) {
drivers/platform/x86/hp-wmi.c static int hp_wmi_read_int(int query) · line 352
Quoted 8 lines
drivers/platform/x86/hp-wmi.c +1
-1@@ -337,7 +346,7 @@ static int hp_wmi_read_int(int query)int val =0 , ret; ret =hp_wmi_perform_query (query,HPWMI_READ , &val, -sizeof (val),sizeof (val)); +0 ,sizeof (val));if (ret)return ret <0 ? ret : -EINVAL ;
This change impacts all callers of hp_wmi_read_int(), please put this in a new 1/4 patch with its own commit message giving more details about this change.
Quoted 7 lines
drivers/platform/x86/hp-wmi.c +1
-1@@ -345,14 +354,47 @@ static int hp_wmi_read_int(int query)return val; } -static int hp_wmi_hw_state (int mask) +static int hp_wmi_get_dock_state (void ) {
drivers/platform/x86/hp-wmi.c static int hp_wmi_read_int(int query) · line 367
Quoted 10 lines
drivers/platform/x86/hp-wmi.c +4
-1int state =hp_wmi_read_int (HPWMI_HARDWARE_QUERY );if (state <0 )return state; -return !!(state & mask); +if (!(state &HPWMI_DOCK_MASK )) +return 0 ; + +return 1 ;
please use:
return !!(state & HPWMI_DOCK_MASK);
Here so that there only is a single return statement for the success path.
drivers/platform/x86/hp-wmi.c static int hp_wmi_read_int(int query) · line 379
Quoted 12 lines
drivers/platform/x86/hp-wmi.c +12
-0+} + +static int hp_wmi_get_tablet_mode (void ) +{ +char system_device_mode[4 ] = {0 }; +int ret; +bool tablet_found = false; + +const char *chassis_type =dmi_get_system_info (DMI_CHASSIS_TYPE ); + +if (!chassis_type) +return 0 ;
return -ENODEV here so that hp_wmi_input_setup() does not register a SW_TABLET_MODE capability in this case.
Userspace *always* will behave as if the device is not a tablet (e.g. NOT show on screen keyboard when focussing text fields) if the driver advertises SW_TABLET_MODE capability which always reports 0. So it is important to not advertise SW_TABLET_MODE at all when it is not available.
drivers/platform/x86/hp-wmi.c static int hp_wmi_read_int(int query) · line 386
Quoted 7 lines
drivers/platform/x86/hp-wmi.c +7
-0+ + tablet_found =match_string (tablet_chassis_types, +ARRAY_SIZE (tablet_chassis_types), + chassis_type) >=0 ; + +if (!tablet_found) +return 0 ;
Again return -ENODEV.
drivers/platform/x86/hp-wmi.c static int hp_wmi_read_int(int query) · line 392
Quoted 6 lines
drivers/platform/x86/hp-wmi.c +6
-0+ + ret =hp_wmi_perform_query (HPWMI_SYSTEM_DEVICE_MODE ,HPWMI_READ , + system_device_mode,0 ,sizeof (system_device_mode)); + +if (ret <0 ) +return 0 ;
If this fails once it will likely fail always, so please do "return ret" here, so that hp_wmi_input_setup() does not register a SW_TABLET_MODE capability in this case.
drivers/platform/x86/hp-wmi.c static int hp_wmi_read_int(int query) · line 397
Quoted 5 lines
drivers/platform/x86/hp-wmi.c +5
-0+ +if (system_device_mode[0 ] ==DEVICE_MODE_TABLET ) +return 1 ; + +return 0 ;
Please do:
return system_device_mode[0] == DEVICE_MODE_TABLET;
here instead.
Quoted 62 lines
drivers/platform/x86/hp-wmi.c +9
-11}static int omen_thermal_profile_set (int mode)@@ -568,7 +610,7 @@ static ssize_t als_show(struct device *dev, struct device_attribute *attr,static ssize_t dock_show (struct device *dev,struct device_attribute *attr,char *buf) { -int value =hp_wmi_hw_state (HPWMI_DOCK_MASK ); +int value =hp_wmi_get_dock_state ();if (value <0 )return value;return sprintf (buf,"%d\n" , value);@@ -577,7 +619,7 @@ static ssize_t dock_show(struct device *dev, struct device_attribute *attr,static ssize_t tablet_show (struct device *dev,struct device_attribute *attr,char *buf) { -int value =hp_wmi_hw_state (HPWMI_TABLET_MASK ); +int value =hp_wmi_get_tablet_mode ();if (value <0 )return value;return sprintf (buf,"%d\n" , value);@@ -699,10 +741,10 @@ static void hp_wmi_notify(u32 value, void *context)case HPWMI_DOCK_EVENT :if (test_bit (SW_DOCK , hp_wmi_input_dev->swbit))input_report_switch (hp_wmi_input_dev,SW_DOCK , -hp_wmi_hw_state (HPWMI_DOCK_MASK )); +hp_wmi_get_dock_state ());if (test_bit (SW_TABLET_MODE , hp_wmi_input_dev->swbit))input_report_switch (hp_wmi_input_dev,SW_TABLET_MODE , -hp_wmi_hw_state (HPWMI_TABLET_MASK )); +hp_wmi_get_tablet_mode ());input_sync (hp_wmi_input_dev);break ;case HPWMI_PARK_HDD :@@ -780,19 +822,17 @@ static int __init hp_wmi_input_setup(void)__set_bit (EV_SW , hp_wmi_input_dev->evbit);/* Dock */ - val =hp_wmi_hw_state (HPWMI_DOCK_MASK ); + val =hp_wmi_get_dock_state ();if (!(val <0 )) {__set_bit (SW_DOCK , hp_wmi_input_dev->swbit);input_report_switch (hp_wmi_input_dev,SW_DOCK , val); }/* Tablet mode */ -if (enable_tablet_mode_sw >0 ) { - val =hp_wmi_hw_state (HPWMI_TABLET_MASK ); -if (val >=0 ) { -__set_bit (SW_TABLET_MODE , hp_wmi_input_dev->swbit); -input_report_switch (hp_wmi_input_dev,SW_TABLET_MODE , val); - } + val =hp_wmi_get_tablet_mode (); +if (!(val <0 )) { +__set_bit (SW_TABLET_MODE , hp_wmi_input_dev->swbit); +input_report_switch (hp_wmi_input_dev,SW_TABLET_MODE , val); } err =sparse_keymap_setup (hp_wmi_input_dev, hp_wmi_keymap,NULL );@@ -1227,10 +1267,10 @@ static int hp_wmi_resume_handler(struct device *device)if (hp_wmi_input_dev) {if (test_bit (SW_DOCK , hp_wmi_input_dev->swbit))
drivers/platform/x86/hp-wmi.c static int hp_wmi_resume_handler(struct device *device) · line 1276
Quoted 10 lines
drivers/platform/x86/hp-wmi.c +2
-2input_report_switch (hp_wmi_input_dev,SW_DOCK , -hp_wmi_hw_state (HPWMI_DOCK_MASK )); +hp_wmi_get_dock_state ());if (test_bit (SW_TABLET_MODE , hp_wmi_input_dev->swbit))input_report_switch (hp_wmi_input_dev,SW_TABLET_MODE , -hp_wmi_hw_state (HPWMI_TABLET_MASK )); +hp_wmi_get_tablet_mode ());input_sync (hp_wmi_input_dev); }
Regards,
Hans
PATCH v4 2/3 Fix 0x05 error code reported by several WMI calls
In reply to Jorge LopezSeveral 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_QUERYHPWMI_HDDTEMP_QUERYHPWMI_ALS_QUERYHPWMI_HARDWARE_QUERYHPWMI_WIRELESS_QUERYHPWMI_BIOS_QUERYHPWMI_FEATURE_QUERYHPWMI_HOTKEY_QUERYHPWMI_FEATURE2_QUERYHPWMI_WIRELESS2_QUERYHPWMI_POSTCODEERROR_QUERYHPWMI_THERMAL_PROFILE_QUERYHPWMI_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.
---
Based on the latest platform-drivers-x86.git/for-next
--- drivers/platform/x86/hp-wmi.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-)
drivers/platform/x86/hp-wmi.c +11 -11
@@ -329,7 +329,7 @@ static int hp_wmi_get_fan_speed(int fan)char fan_data[4 ] = { fan,0 ,0 ,0 };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));if (ret !=0 )
@@ -406,7 +406,7 @@ static int omen_thermal_profile_set(int mode)return -EINVAL ; ret =hp_wmi_perform_query (HPWMI_SET_PERFORMANCE_MODE ,HPWMI_GM , - &buffer,sizeof (buffer),sizeof (buffer)); + &buffer,sizeof (buffer),0 );if (ret)return ret <0 ? ret : -EINVAL ;
@@ -443,7 +443,7 @@ static int hp_wmi_fan_speed_max_set(int enabled)int ret; ret =hp_wmi_perform_query (HPWMI_FAN_SPEED_MAX_SET_QUERY ,HPWMI_GM , - &enabled,sizeof (enabled),sizeof (enabled)); + &enabled,sizeof (enabled),0 );if (ret)return ret <0 ? ret : -EINVAL ;
@@ -456,7 +456,7 @@ static int hp_wmi_fan_speed_max_get(void)int val =0 , ret; ret =hp_wmi_perform_query (HPWMI_FAN_SPEED_MAX_GET_QUERY ,HPWMI_GM , - &val,sizeof (val),sizeof (val)); + &val,0 ,sizeof (val));if (ret)return ret <0 ? ret : -EINVAL ;
@@ -468,7 +468,7 @@ static int __init hp_wmi_bios_2008_later(void) {int state =0 ;int ret =hp_wmi_perform_query (HPWMI_FEATURE_QUERY ,HPWMI_READ , &state, -sizeof (state),sizeof (state)); +0 ,sizeof (state));if (!ret)return 1 ;
@@ -479,7 +479,7 @@ static int __init hp_wmi_bios_2009_later(void) {u8 state[128 ];int ret =hp_wmi_perform_query (HPWMI_FEATURE2_QUERY ,HPWMI_READ , &state, -sizeof (state),sizeof (state)); +0 ,sizeof (state));if (!ret)return 1 ;
@@ -557,7 +557,7 @@ static int hp_wmi_rfkill2_refresh(void)int err, i; err =hp_wmi_perform_query (HPWMI_WIRELESS2_QUERY ,HPWMI_READ , &state, -sizeof (state),sizeof (state)); +0 ,sizeof (state));if (err)return err;
@@ -646,7 +646,7 @@ static ssize_t als_store(struct device *dev, struct device_attribute *attr,return ret; ret =hp_wmi_perform_query (HPWMI_ALS_QUERY ,HPWMI_WRITE , &tmp, -sizeof (tmp),sizeof (tmp)); +sizeof (tmp),0 );if (ret)return ret <0 ? ret : -EINVAL ;
@@ -667,9 +667,9 @@ static ssize_t postcode_store(struct device *dev, struct device_attribute *attr,if (clear == false)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, -sizeof (tmp),sizeof (tmp)); +sizeof (tmp),0 );if (ret)return ret <0 ? ret : -EINVAL ;
@@ -959,7 +959,7 @@ static int __init hp_wmi_rfkill2_setup(struct platform_device *device)int err, i; err =hp_wmi_perform_query (HPWMI_WIRELESS2_QUERY ,HPWMI_READ , &state, -sizeof (state),sizeof (state)); +0 ,sizeof (state));if (err)return err <0 ? err : -EINVAL ;
Signature · 1 line
2.25.1
Re: [PATCH v4 2/3] Fix 0x05 error code reported by several WMI calls
Hi,
Quoted 29 lines · Jorge Lopez
Several WMI queries leverage
hp_wmi_read_intfunction to read their data.hp_wmi_read_intfunction was corrected in a previous patch. Now, this function invokeshp_wmi_perform_querywith input parameter of size zero and the output buffer of size 4.WMI commands calling
hp_wmi_perform_querywith input buffer size value of zero are listed below.
HPWMI_DISPLAY_QUERYHPWMI_HDDTEMP_QUERYHPWMI_ALS_QUERYHPWMI_HARDWARE_QUERYHPWMI_WIRELESS_QUERYHPWMI_BIOS_QUERYHPWMI_FEATURE_QUERYHPWMI_HOTKEY_QUERYHPWMI_FEATURE2_QUERYHPWMI_WIRELESS2_QUERYHPWMI_POSTCODEERROR_QUERYHPWMI_THERMAL_PROFILE_QUERYHPWMI_FAN_SPEED_MAX_GET_QUERYInvoking those WMI commands with an input buffer size greater than zero will cause error
0x05to 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.
Quoted 6 lines
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]>
Thanks, patch looks good to me:
Regards,
Hans
Quoted 104 lines
---
Based on the latest platform-drivers-x86.git/for-next--- drivers/platform/x86/hp-wmi.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-)drivers/platform/x86/hp-wmi.c +11
-11@@ -329,7 +329,7 @@ static int hp_wmi_get_fan_speed(int fan)char fan_data[4 ] = { fan,0 ,0 ,0 };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));if (ret !=0 )@@ -406,7 +406,7 @@ static int omen_thermal_profile_set(int mode)return -EINVAL ; ret =hp_wmi_perform_query (HPWMI_SET_PERFORMANCE_MODE ,HPWMI_GM , - &buffer,sizeof (buffer),sizeof (buffer)); + &buffer,sizeof (buffer),0 );if (ret)return ret <0 ? ret : -EINVAL ;@@ -443,7 +443,7 @@ static int hp_wmi_fan_speed_max_set(int enabled)int ret; ret =hp_wmi_perform_query (HPWMI_FAN_SPEED_MAX_SET_QUERY ,HPWMI_GM , - &enabled,sizeof (enabled),sizeof (enabled)); + &enabled,sizeof (enabled),0 );if (ret)return ret <0 ? ret : -EINVAL ;@@ -456,7 +456,7 @@ static int hp_wmi_fan_speed_max_get(void)int val =0 , ret; ret =hp_wmi_perform_query (HPWMI_FAN_SPEED_MAX_GET_QUERY ,HPWMI_GM , - &val,sizeof (val),sizeof (val)); + &val,0 ,sizeof (val));if (ret)return ret <0 ? ret : -EINVAL ;@@ -468,7 +468,7 @@ static int __init hp_wmi_bios_2008_later(void) {int state =0 ;int ret =hp_wmi_perform_query (HPWMI_FEATURE_QUERY ,HPWMI_READ , &state, -sizeof (state),sizeof (state)); +0 ,sizeof (state));if (!ret)return 1 ;@@ -479,7 +479,7 @@ static int __init hp_wmi_bios_2009_later(void) {u8 state[128 ];int ret =hp_wmi_perform_query (HPWMI_FEATURE2_QUERY ,HPWMI_READ , &state, -sizeof (state),sizeof (state)); +0 ,sizeof (state));if (!ret)return 1 ;@@ -557,7 +557,7 @@ static int hp_wmi_rfkill2_refresh(void)int err, i; err =hp_wmi_perform_query (HPWMI_WIRELESS2_QUERY ,HPWMI_READ , &state, -sizeof (state),sizeof (state)); +0 ,sizeof (state));if (err)return err;@@ -646,7 +646,7 @@ static ssize_t als_store(struct device *dev, struct device_attribute *attr,return ret; ret =hp_wmi_perform_query (HPWMI_ALS_QUERY ,HPWMI_WRITE , &tmp, -sizeof (tmp),sizeof (tmp)); +sizeof (tmp),0 );if (ret)return ret <0 ? ret : -EINVAL ;@@ -667,9 +667,9 @@ static ssize_t postcode_store(struct device *dev, struct device_attribute *attr,if (clear == false)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, -sizeof (tmp),sizeof (tmp)); +sizeof (tmp),0 );if (ret)return ret <0 ? ret : -EINVAL ;@@ -959,7 +959,7 @@ static int __init hp_wmi_rfkill2_setup(struct platform_device *device)int err, i; err =hp_wmi_perform_query (HPWMI_WIRELESS2_QUERY ,HPWMI_READ , &state, -sizeof (state),sizeof (state)); +0 ,sizeof (state));if (err)return err <0 ? err : -EINVAL ;
PATCH v4 3/3 Changing bios_args.data to be dynamically allocated
In reply to Jorge LopezThe purpose of this patch is to remove 128 bytes buffer limitation imposed in bios_args structure.
A limiting factor discovered during this investigation was the struct bios_args.data size restriction. The data member size limits all possible WMI commands to those requiring buffer size of 128 bytes or less. Several WMI commands and queries require a buffer size larger than 128 bytes hence limiting current and feature supported by the driver. It is for this reason, struct bios_args.data changed and is dynamically allocated. hp_wmi_perform_query function changed to handle the memory allocation and release of any required buffer size.
All 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.
---
Based on the latest platform-drivers-x86.git/for-next
--- drivers/platform/x86/hp-wmi.c | 59 ++++++++++++++++++++++------------- 1 file changed, 38 insertions(+), 21 deletions(-)
drivers/platform/x86/hp-wmi.c +38 -21
@@ -82,12 +82,17 @@ enum hp_wmi_event_ids { HPWMI_BATTERY_CHARGE_PERIOD = 0x10, }; +/** +* struct bios_args buffer is dynamically allocated. New WMI command types +* were introduced that exceeds 128-byte data size. Changes to handle +* the data size allocation scheme were kept in hp_wmi_perform_qurey function. +*/ struct bios_args {u32 signature;u32 command;u32 commandtype;u32 datasize; -u8 data[128 ]; +u8 data[0 ]; };enum hp_wmi_commandtype {
@@ -268,34 +273,39 @@ static int hp_wmi_perform_query(int query, enum hp_wmi_command command,int mid;struct bios_return *bios_return;int actual_outsize; -union acpi_object *obj; -struct bios_args args = { - .signature =0x55434553 , - .command = command, - .commandtype = query, - .datasize = insize, - .data = {0 }, - }; -struct acpi_buffer input = {sizeof (struct bios_args ), &args }; +union acpi_object *obj =NULL ; +size_t bios_args_size =sizeof (struct bios_args ) + insize; +struct bios_args *args =NULL ; +struct acpi_buffer input;struct acpi_buffer output = {ACPI_ALLOCATE_BUFFER ,NULL };int ret =0 ; - mid =encode_outsize_for_pvsz (outsize); -if (WARN_ON (mid <0 )) -return mid; + args =kmalloc (bios_args_size,GFP_KERNEL ); +if (!args) +return -ENOMEM ; -if (WARN_ON (insize >sizeof (args.data))) -return -EINVAL ; -memcpy (&args.data[0 ], buffer, insize); + input.length = bios_args_size; + input.pointer = args; -wmi_evaluate_method (HPWMI_BIOS_GUID ,0 , mid, &input, &output); + mid =encode_outsize_for_pvsz (outsize); +if (WARN_ON (mid <0 )) { + ret = mid; + goto out_free; + } - obj = output.pointer; +memcpy (args->data, buffer, insize); -if (!obj) -return -EINVAL ; + args->signature =0x55434553 ; + args->command = command; + args->commandtype = query; + args->datasize = insize; -if (obj->type !=ACPI_TYPE_BUFFER ) { + ret =wmi_evaluate_method (HPWMI_BIOS_GUID ,0 , mid, &input, &output); +if (ret) + goto out_free; + + obj = output.pointer; +if (!obj) { ret = -EINVAL ; goto out_free; }
@@ -310,6 +320,12 @@ static int hp_wmi_perform_query(int query, enum hp_wmi_command command, goto out_free; } +if (obj->type !=ACPI_TYPE_BUFFER ) { +pr_warn ("query 0x%x returned an invalid object 0x%x\n" , query, ret); + ret = -EINVAL ; + goto out_free; + } +/* Ignore output data of zero size */ if (!outsize) goto out_free;
@@ -320,6 +336,7 @@ static int hp_wmi_perform_query(int query, enum hp_wmi_command command, out_free:kfree (obj); +kfree (args);return ret; }
Signature · 1 line
2.25.1
RE: [PATCH v4 3/3] Changing bios_args.data to be dynamically allocated
[Public]
Quoted 23 lines
-----Original Message-----
From: Jorge Lopez <[email protected]>
Sent: Monday, March 7, 2022 16:10
To: [email protected]
Subject: [PATCH v4 3/3] Changing bios_args.data to be dynamically allocatedThe purpose of this patch is to remove 128 bytes buffer limitation imposed in
bios_argsstructure.A limiting factor discovered during this investigation was the struct bios_args.data size restriction. The data member size limits all possible WMI commands to those requiring buffer size of 128 bytes or less. Several WMI commands and queries require a buffer size larger than 128 bytes hence limiting current and feature supported by the driver. It is for this reason, struct bios_args.data changed and is dynamically allocated.
hp_wmi_perform_queryfunction changed to handle the memory allocation and release of any required buffer size.All 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.
Quoted 4 lines
Signed-off-by Jorge Lopez <[email protected]>---
Based on the latest platform-drivers-x86.git/for-next
Was this meant as "changes from v3->v4"? Or it's just a comment?
Quoted 1 line
---
No need for double --. Just put everything commentary below the one --.
Quoted 117 lines
drivers/platform/x86/hp-wmi.c | 59 ++++++++++++++++++++++------------- 1 file changed, 38 insertions(+), 21 deletions(-)drivers/platform/x86/hp-wmi.c +2
-0@@ -82,12 +82,17 @@ enum hp_wmi_event_ids { HPWMI_BATTERY_CHARGE_PERIOD = 0x10, }; +/** +* struct bios_args buffer is dynamically allocated. New WMI command types
+ * were introduced that exceeds 128-byte data size. Changes to handle
+ * the data size allocation scheme were kept inhp_wmi_perform_qureyfunction.
+ */
structbios_args{drivers/platform/x86/hp-wmi.c +26
-21u32 signature;u32 command;u32 commandtype;u32 datasize; -u8 data[128 ]; +u8 data[0 ]; };enum hp_wmi_commandtype {@@ -268,34 +273,39 @@ static int hp_wmi_perform_query(int query, enumhp_wmi_command command, int mid;struct bios_return *bios_return;int actual_outsize; -union acpi_object *obj; -struct bios_args args = { - .signature =0x55434553 , - .command = command, - .commandtype = query, - .datasize = insize, - .data = {0 }, - }; -struct acpi_buffer input = {sizeof (struct bios_args ), &args }; +union acpi_object *obj =NULL ; +size_t bios_args_size =sizeof (struct bios_args ) + insize; +struct bios_args *args =NULL ; +struct acpi_buffer input;struct acpi_buffer output = {ACPI_ALLOCATE_BUFFER ,NULL };int ret =0 ; - mid =encode_outsize_for_pvsz (outsize); -if (WARN_ON (mid <0 )) -return mid; + args =kmalloc (bios_args_size,GFP_KERNEL ); +if (!args) +return -ENOMEM ; -if (WARN_ON (insize >sizeof (args.data))) -return -EINVAL ; -memcpy (&args.data[0 ], buffer, insize); + input.length = bios_args_size; + input.pointer = args; -wmi_evaluate_method (HPWMI_BIOS_GUID ,0 , mid, &input, &output); + mid =encode_outsize_for_pvsz (outsize); +if (WARN_ON (mid <0 )) { + ret = mid; + goto out_free; + } - obj = output.pointer; +memcpy (args->data, buffer, insize); -if (!obj) -return -EINVAL ; + args->signature =0x55434553 ; + args->command = command; + args->commandtype = query; + args->datasize = insize; -if (obj->type !=ACPI_TYPE_BUFFER ) { + ret =wmi_evaluate_method (HPWMI_BIOS_GUID ,0 , mid, &input, &output); +if (ret) + goto out_free; + + obj = output.pointer; +if (!obj) {drivers/platform/x86/hp-wmi.c +6
-0ret = -EINVAL ; goto out_free; }@@ -310,6 +320,12 @@ static int hp_wmi_perform_query(int query, enumhp_wmi_command command, goto out_free; } +if (obj->type !=ACPI_TYPE_BUFFER ) { +pr_warn ("query 0x%x returned an invalid object 0x%x\n" , query, ret); + ret = -EINVAL ; + goto out_free; + } +/* Ignore output data of zero size */ drivers/platform/x86/hp-wmi.c +1
-1if (!outsize) goto out_free;@@ -320,6 +336,7 @@ static int hp_wmi_perform_query(int query, enumhp_wmi_command command, out_free:kfree (obj ); +kfree (args);return ret; } --2.25.1
A message that is not in the archive (sent off-list or not yet received): CAOOmCE89Tj00ZTAh2Jnf_ALX0LKz8AkRteC1PS2Rvjx-Y1HScA@mail.gmail.com
RE: [PATCH v4 3/3] Changing bios_args.data to be dynamically allocated
[Public]
Quoted 1 line
The only changes apply to V3-0001. Patches V3-0002 and V3-0003 did not changed in version V4.
In general it's nice to include either in your cover letter "changes from X-Y" or in individual patches below the --. It makes it easier for anyone who reviewed previous version to spot the differences.
Re: [PATCH v4 3/3] Changing bios_args.data to be dynamically allocated
In reply to Limonciello, MarioHi,
Quoted 29 lines · Mario
[Public]
Quoted 25 lines
-----Original Message-----
From: Jorge Lopez <[email protected]>
Sent: Monday, March 7, 2022 16:10
To: [email protected]
Subject: [PATCH v4 3/3] Changing bios_args.data to be dynamically allocatedThe purpose of this patch is to remove 128 bytes buffer limitation imposed in
bios_argsstructure.A limiting factor discovered during this investigation was the struct bios_args.data size restriction. The data member size limits all possible WMI commands to those requiring buffer size of 128 bytes or less. Several WMI commands and queries require a buffer size larger than 128 bytes hence limiting current and feature supported by the driver. It is for this reason, struct bios_args.data changed and is dynamically allocated.
hp_wmi_perform_queryfunction changed to handle the memory allocation and release of any required buffer size.All 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]>
Quoted 8 lines
Quoted 2 lines
---
Based on the latest platform-drivers-x86.git/for-nextWas this meant as "changes from
v3->v4"? Or it's just a comment?Quoted 1 line
---
No need for double --. Just put everything commentary below the one --.
The second cut-line gets added by git format-patch, there is nothing which can be done about that.
Regards,
Hans
Quoted 119 lines
Quoted 118 lines
drivers/platform/x86/hp-wmi.c | 59 ++++++++++++++++++++++------------- 1 file changed, 38 insertions(+), 21 deletions(-)drivers/platform/x86/hp-wmi.c +2
-0@@ -82,12 +82,17 @@ enum hp_wmi_event_ids { HPWMI_BATTERY_CHARGE_PERIOD = 0x10, }; +/** +* struct bios_args buffer is dynamically allocated. New WMI command types
+ * were introduced that exceeds 128-byte data size. Changes to handle
+ * the data size allocation scheme were kept inhp_wmi_perform_qureyfunction.
+ */
structbios_args{drivers/platform/x86/hp-wmi.c +26
-21u32 signature;u32 command;u32 commandtype;u32 datasize; -u8 data[128 ]; +u8 data[0 ]; };enum hp_wmi_commandtype {@@ -268,34 +273,39 @@ static int hp_wmi_perform_query(int query, enumhp_wmi_command command, int mid;struct bios_return *bios_return;int actual_outsize; -union acpi_object *obj; -struct bios_args args = { - .signature =0x55434553 , - .command = command, - .commandtype = query, - .datasize = insize, - .data = {0 }, - }; -struct acpi_buffer input = {sizeof (struct bios_args ), &args }; +union acpi_object *obj =NULL ; +size_t bios_args_size =sizeof (struct bios_args ) + insize; +struct bios_args *args =NULL ; +struct acpi_buffer input;struct acpi_buffer output = {ACPI_ALLOCATE_BUFFER ,NULL };int ret =0 ; - mid =encode_outsize_for_pvsz (outsize); -if (WARN_ON (mid <0 )) -return mid; + args =kmalloc (bios_args_size,GFP_KERNEL ); +if (!args) +return -ENOMEM ; -if (WARN_ON (insize >sizeof (args.data))) -return -EINVAL ; -memcpy (&args.data[0 ], buffer, insize); + input.length = bios_args_size; + input.pointer = args; -wmi_evaluate_method (HPWMI_BIOS_GUID ,0 , mid, &input, &output); + mid =encode_outsize_for_pvsz (outsize); +if (WARN_ON (mid <0 )) { + ret = mid; + goto out_free; + } - obj = output.pointer; +memcpy (args->data, buffer, insize); -if (!obj) -return -EINVAL ; + args->signature =0x55434553 ; + args->command = command; + args->commandtype = query; + args->datasize = insize; -if (obj->type !=ACPI_TYPE_BUFFER ) { + ret =wmi_evaluate_method (HPWMI_BIOS_GUID ,0 , mid, &input, &output); +if (ret) + goto out_free; + + obj = output.pointer; +if (!obj) {drivers/platform/x86/hp-wmi.c +6
-0ret = -EINVAL ; goto out_free; }@@ -310,6 +320,12 @@ static int hp_wmi_perform_query(int query, enumhp_wmi_command command, goto out_free; } +if (obj->type !=ACPI_TYPE_BUFFER ) { +pr_warn ("query 0x%x returned an invalid object 0x%x\n" , query, ret); + ret = -EINVAL ; + goto out_free; + } +/* Ignore output data of zero size */ drivers/platform/x86/hp-wmi.c +1
-1if (!outsize) goto out_free;@@ -320,6 +336,7 @@ static int hp_wmi_perform_query(int query, enumhp_wmi_command command, out_free:kfree (obj ); +kfree (args);return ret; } --2.25.1
Re: [PATCH v4 3/3] Changing bios_args.data to be dynamically allocated
In reply to Jorge LopezHi,
Quoted 35 lines · Jorge Lopez
The purpose of this patch is to remove 128 bytes buffer limitation imposed in
bios_argsstructure.A limiting factor discovered during this investigation was the struct bios_args.data size restriction. The data member size limits all possible WMI commands to those requiring buffer size of 128 bytes or less. Several WMI commands and queries require a buffer size larger than 128 bytes hence limiting current and feature supported by the driver. It is for this reason, struct bios_args.data changed and is dynamically allocated.
hp_wmi_perform_queryfunction changed to handle the memory allocation and release of any required buffer size.All 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]>---
Based on the latest platform-drivers-x86.git/for-next--- drivers/platform/x86/hp-wmi.c | 59 ++++++++++++++++++++++------------- 1 file changed, 38 insertions(+), 21 deletions(-)drivers/platform/x86/hp-wmi.c +2
-0@@ -82,12 +82,17 @@ enum hp_wmi_event_ids { HPWMI_BATTERY_CHARGE_PERIOD = 0x10, }; +/** +* struct bios_args buffer is dynamically allocated. New WMI command types
drivers/platform/x86/hp-wmi.c enum hp_wmi_event_ids { · line 95
Quoted 10 lines
drivers/platform/x86/hp-wmi.c +4
-1+* were introduced that exceeds 128-byte data size. Changes to handle +* the data size allocation scheme were kept in hp_wmi_perform_qurey function. +*/ struct bios_args {u32 signature;u32 command;u32 commandtype;u32 datasize; -u8 data[128 ]; +u8 data[0 ];
This should be:
u8 data[];
See:
https://docs.kernel.org/process/deprecated.html#zero-length-and-one-element-arrays
Quoted 8 lines
drivers/platform/x86/hp-wmi.c +0
-1};enum hp_wmi_commandtype {@@ -268,34 +273,39 @@ static int hp_wmi_perform_query(int query, enum hp_wmi_command command,int mid;struct bios_return *bios_return;int actual_outsize; -union acpi_object *obj;
drivers/platform/x86/hp-wmi.c static int hp_wmi_perform_query(int query, enum hp_wmi_command command, · line 277
Quoted 10 lines
drivers/platform/x86/hp-wmi.c +2
-8-struct bios_args args = { - .signature =0x55434553 , - .command = command, - .commandtype = query, - .datasize = insize, - .data = {0 }, - }; -struct acpi_buffer input = {sizeof (struct bios_args ), &args }; +union acpi_object *obj =NULL ; +size_t bios_args_size =sizeof (struct bios_args ) + insize;
Please use the struct_size() macro for this, see the end of:
https://docs.kernel.org/process/deprecated.html#zero-length-and-one-element-arrays
for an example.
Quoted 48 lines
drivers/platform/x86/hp-wmi.c +23
-11+struct bios_args *args =NULL ; +struct acpi_buffer input;struct acpi_buffer output = {ACPI_ALLOCATE_BUFFER ,NULL };int ret =0 ; - mid =encode_outsize_for_pvsz (outsize); -if (WARN_ON (mid <0 )) -return mid; + args =kmalloc (bios_args_size,GFP_KERNEL ); +if (!args) +return -ENOMEM ; -if (WARN_ON (insize >sizeof (args.data))) -return -EINVAL ; -memcpy (&args.data[0 ], buffer, insize); + input.length = bios_args_size; + input.pointer = args; -wmi_evaluate_method (HPWMI_BIOS_GUID ,0 , mid, &input, &output); + mid =encode_outsize_for_pvsz (outsize); +if (WARN_ON (mid <0 )) { + ret = mid; + goto out_free; + } - obj = output.pointer; +memcpy (args->data, buffer, insize); -if (!obj) -return -EINVAL ; + args->signature =0x55434553 ; + args->command = command; + args->commandtype = query; + args->datasize = insize; -if (obj->type !=ACPI_TYPE_BUFFER ) { + ret =wmi_evaluate_method (HPWMI_BIOS_GUID ,0 , mid, &input, &output); +if (ret) + goto out_free; + + obj = output.pointer; +if (!obj) { ret = -EINVAL ; goto out_free; }@@ -310,6 +320,12 @@ static int hp_wmi_perform_query(int query, enum hp_wmi_command command, goto out_free; }
drivers/platform/x86/hp-wmi.c static int hp_wmi_perform_query(int query, enum hp_wmi_command command, · line 331
Quoted 10 lines
drivers/platform/x86/hp-wmi.c +6
-0+if (obj->type !=ACPI_TYPE_BUFFER ) { +pr_warn ("query 0x%x returned an invalid object 0x%x\n" , query, ret); + ret = -EINVAL ; + goto out_free; + } +/* Ignore output data of zero size */ if (!outsize) goto out_free;
Should we maybe have a "ret = -EINVAL" here, or
maybe ret = 0 ? Or is ret always 0 here already ?
drivers/platform/x86/hp-wmi.c static int hp_wmi_perform_query(int query, enum hp_wmi_command command, · line 342
Quoted 8 lines
drivers/platform/x86/hp-wmi.c +1
-0@@ -320,6 +336,7 @@ static int hp_wmi_perform_query(int query, enum hp_wmi_command command, out_free:kfree (obj); +kfree (args);return ret; }
Otherwise this looks good to me.
Regards,
Hans