hp-bioscfg: Overall fixes and code cleanup
Subsystems (2)
cover hp-bioscfg: Overall fixes and code cleanup
Submit individual patches to address memory leaks and uninitialized variable errors.
Addressed several review comments making the source code more readable. Removed duplicate use of variable in inner loop.
Changes were tested with a HP EliteBook x360 1030 G3
Jorge Lopez (8):
hp-bioscfg: Fix memory leaks in attribute packages
hp-bioscfg: Fix uninitialized variable errors
hp-bioscfg: Replace the word HACK from source code
hp-bioscfg: Change how prerequisites size is evaluated
hp-bioscfg: Change how order list size is evaluated
hp-bioscfg: Change how enum possible values size is evaluated
hp-bioscfg: Change how password encoding size is evaluated
hp-bioscfg: Remove duplicate use of variable in inner loop
.../x86/hp/hp-bioscfg/enum-attributes.c | 24 ++++++++---- .../x86/hp/hp-bioscfg/int-attributes.c | 15 +++++-- .../x86/hp/hp-bioscfg/order-list-attributes.c | 39 ++++++++++++------- .../x86/hp/hp-bioscfg/passwdobj-attributes.c | 27 +++++++++---- .../x86/hp/hp-bioscfg/string-attributes.c | 13 +++++-- 5 files changed, 82 insertions(+), 36 deletions(-)
--
2.34.1
PATCH 1/8 hp-bioscfg: Fix memory leaks in attribute packages
Address memory leaks while handling elements in packages.
---
Based on the latest platform-drivers-x86.git/for-next
--- drivers/platform/x86/hp/hp-bioscfg/enum-attributes.c | 6 ++++++ drivers/platform/x86/hp/hp-bioscfg/int-attributes.c | 5 +++++ .../platform/x86/hp/hp-bioscfg/order-list-attributes.c | 6 ++++++ drivers/platform/x86/hp/hp-bioscfg/passwdobj-attributes.c | 8 ++++++++ drivers/platform/x86/hp/hp-bioscfg/string-attributes.c | 3 +++ 5 files changed, 28 insertions(+)
drivers/platform/x86/hp/hp-bioscfg/enum-attributes.c +6 -0
@@ -164,6 +164,7 @@ static int hp_populate_enumeration_elements_from_package(union acpi_object *enumif (expected_enum_types[eloc] != enum_obj[elem].type) {pr_err ("Error expected type %d for elem %d, but got type %d instead\n" , expected_enum_types[eloc], elem, enum_obj[elem].type); +kfree (str_value);return -EIO ; }
@@ -224,6 +225,7 @@ static int hp_populate_enumeration_elements_from_package(union acpi_object *enum sizeof(enum_data->common.prerequisites[reqs]));kfree (str_value); + str_value =NULL ; }break ;
@@ -275,6 +277,9 @@ static int hp_populate_enumeration_elements_from_package(union acpi_object *enumstrscpy (enum_data->possible_values[pos_values], str_value,sizeof (enum_data->possible_values[pos_values])); + +kfree (str_value); + str_value =NULL ; }break ;default :
@@ -283,6 +288,7 @@ static int hp_populate_enumeration_elements_from_package(union acpi_object *enum }kfree (str_value); + str_value =NULL ; } exit_enumeration_package:
drivers/platform/x86/hp/hp-bioscfg/int-attributes.c +5 -0
@@ -179,6 +179,7 @@ static int hp_populate_integer_elements_from_package(union acpi_object *integer_if (expected_integer_types[eloc] != integer_obj[elem].type) {pr_err ("Error expected type %d for elem %d, but got type %d instead\n" , expected_integer_types[eloc], elem, integer_obj[elem].type); +kfree (str_value);return -EIO ; }/* Assign appropriate element value to corresponding field*/
@@ -239,6 +240,7 @@ static int hp_populate_integer_elements_from_package(union acpi_object *integer_ str_value, sizeof(integer_data->common.prerequisites[reqs]));kfree (str_value); + str_value =NULL ; }break ;
@@ -258,6 +260,9 @@ static int hp_populate_integer_elements_from_package(union acpi_object *integer_pr_warn ("Invalid element: %d found in Integer attribute or data may be malformed\n" , elem);break ; } + +kfree (str_value); + str_value =NULL ; } exit_integer_package:kfree (str_value);
drivers/platform/x86/hp/hp-bioscfg/order-list-attributes.c +6 -0
@@ -174,6 +174,7 @@ static int hp_populate_ordered_list_elements_from_package(union acpi_object *ordif (expected_order_types[eloc] != order_obj[elem].type) {pr_err ("Error expected type %d for elem %d, but got type %d instead\n" , expected_order_types[eloc], elem, order_obj[elem].type); +kfree (str_value);return -EIO ; }
@@ -231,6 +232,7 @@ static int hp_populate_ordered_list_elements_from_package(union acpi_object *ord sizeof(ordered_list_data->common.prerequisites[reqs]));kfree (str_value); + str_value =NULL ; }break ;
@@ -277,13 +279,17 @@ static int hp_populate_ordered_list_elements_from_package(union acpi_object *ord part =strsep (&part_tmp,SEMICOLON_SEP ); } +kfree (str_value); + str_value =NULL ;break ;default :pr_warn ("Invalid element: %d found in Ordered_List attribute or data may be malformed\n" , elem);break ; }kfree (tmpstr); + tmpstr =NULL ;kfree (str_value); + str_value =NULL ; } exit_list:
drivers/platform/x86/hp/hp-bioscfg/passwdobj-attributes.c +8 -0
@@ -264,6 +264,7 @@ static int hp_populate_password_elements_from_package(union acpi_object *passworif (expected_password_types[eloc] != password_obj[elem].type) {pr_err ("Error expected type %d for elem %d, but got type %d instead\n" , expected_password_types[eloc], elem, password_obj[elem].type); +kfree (str_value);return -EIO ; }
@@ -318,6 +319,8 @@ static int hp_populate_password_elements_from_package(union acpi_object *passwor sizeof(password_data->common.prerequisites[reqs]));kfree (str_value); + str_value =NULL ; + }break ;case SECURITY_LEVEL :
@@ -356,6 +359,8 @@ static int hp_populate_password_elements_from_package(union acpi_object *passwor str_value, sizeof(password_data->encodings[pos_values]));kfree (str_value); + str_value =NULL ; + }break ;case PSWD_IS_SET :
@@ -365,6 +370,9 @@ static int hp_populate_password_elements_from_package(union acpi_object *passworpr_warn ("Invalid element: %d found in Password attribute or data may be malformed\n" , elem);break ; } + +kfree (str_value); + str_value =NULL ; } exit_package:
drivers/platform/x86/hp/hp-bioscfg/string-attributes.c +3 -0
@@ -171,6 +171,7 @@ static int hp_populate_string_elements_from_package(union acpi_object *string_obif (expected_string_types[eloc] != string_obj[elem].type) {pr_err ("Error expected type %d for elem %d, but got type %d instead\n" , expected_string_types[eloc], elem, string_obj[elem].type); +kfree (str_value);return -EIO ; }
@@ -232,6 +233,7 @@ static int hp_populate_string_elements_from_package(union acpi_object *string_ob str_value, sizeof(string_data->common.prerequisites[reqs]));kfree (str_value); + str_value =NULL ; }break ;
@@ -250,6 +252,7 @@ static int hp_populate_string_elements_from_package(union acpi_object *string_ob }kfree (str_value); + str_value =NULL ; } exit_string_package:
Signature · 1 line
2.34.1
PATCH 2/8 hp-bioscfg: Fix uninitialized variable errors
In reply to Jorge LopezFix uninitialized variable errors.
---
Based on the latest platform-drivers-x86.git/for-next
--- drivers/platform/x86/hp/hp-bioscfg/enum-attributes.c | 2 +- drivers/platform/x86/hp/hp-bioscfg/int-attributes.c | 2 +- drivers/platform/x86/hp/hp-bioscfg/order-list-attributes.c | 4 ++-- drivers/platform/x86/hp/hp-bioscfg/passwdobj-attributes.c | 2 +- drivers/platform/x86/hp/hp-bioscfg/string-attributes.c | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-)
drivers/platform/x86/hp/hp-bioscfg/enum-attributes.c +1 -1
@@ -129,7 +129,7 @@ static int hp_populate_enumeration_elements_from_package(union acpi_object *enumchar *str_value =NULL ;int value_len;u32 size =0 ; -u32 int_value; +u32 int_value =0 ;int elem =0 ;int reqs;int pos_values;
drivers/platform/x86/hp/hp-bioscfg/int-attributes.c +1 -1
@@ -143,7 +143,7 @@ static int hp_populate_integer_elements_from_package(union acpi_object *integer_char *str_value =NULL ;int value_len;int ret; -u32 int_value; +u32 int_value =0 ;int elem;int reqs;int eloc;
drivers/platform/x86/hp/hp-bioscfg/order-list-attributes.c +2 -2
@@ -131,10 +131,10 @@ static int hp_populate_ordered_list_elements_from_package(union acpi_object *ord int instance_id) {char *str_value =NULL ; -int value_len; +int value_len =0 ;int ret;u32 size; -u32 int_value; +u32 int_value =0 ;int elem;int reqs;int eloc;
drivers/platform/x86/hp/hp-bioscfg/passwdobj-attributes.c +1 -1
@@ -227,7 +227,7 @@ static int hp_populate_password_elements_from_package(union acpi_object *passworint value_len;int ret;u32 size; -u32 int_value; +u32 int_value =0 ;int elem;int reqs;int eloc;
drivers/platform/x86/hp/hp-bioscfg/string-attributes.c +1 -1
@@ -133,7 +133,7 @@ static int hp_populate_string_elements_from_package(union acpi_object *string_obchar *str_value =NULL ;int value_len;int ret =0 ; -u32 int_value; +u32 int_value =0 ;int elem;int reqs;int eloc;
Signature · 1 line
2.34.1
PATCH 3/8 hp-bioscfg: Replace the word HACK from source code
In reply to Jorge LopezReplace the word 'HACK' with 'step' from source code
---
Based on the latest platform-drivers-x86.git/for-next
--- drivers/platform/x86/hp/hp-bioscfg/enum-attributes.c | 4 ++-- drivers/platform/x86/hp/hp-bioscfg/int-attributes.c | 2 +- drivers/platform/x86/hp/hp-bioscfg/order-list-attributes.c | 4 ++-- drivers/platform/x86/hp/hp-bioscfg/passwdobj-attributes.c | 4 ++-- drivers/platform/x86/hp/hp-bioscfg/string-attributes.c | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-)
drivers/platform/x86/hp/hp-bioscfg/enum-attributes.c +2 -2
@@ -195,7 +195,7 @@ static int hp_populate_enumeration_elements_from_package(union acpi_object *enumpr_warn ("Prerequisites size value exceeded the maximum number of elements supported or data may be malformed\n" );/* -* This HACK is needed to keep the expected +* This step is needed to keep the expected * element list pointing to the right obj[elem].type * when the size is zero. PREREQUISITES * object is omitted by BIOS when the size is
@@ -243,7 +243,7 @@ static int hp_populate_enumeration_elements_from_package(union acpi_object *enumpr_warn ("Possible number values size value exceeded the maximum number of elements supported or data may be malformed\n" );/* -* This HACK is needed to keep the expected +* This step is needed to keep the expected * element list pointing to the right obj[elem].type * when the size is zero. POSSIBLE_VALUES * object is omitted by BIOS when the size is zero.
drivers/platform/x86/hp/hp-bioscfg/int-attributes.c +1 -1
@@ -211,7 +211,7 @@ static int hp_populate_integer_elements_from_package(union acpi_object *integer_if (integer_data->common.prerequisites_size >MAX_PREREQUISITES_SIZE )pr_warn ("Prerequisites size value exceeded the maximum number of elements supported or data may be malformed\n" );/* -* This HACK is needed to keep the expected +* This step is needed to keep the expected * element list pointing to the right obj[elem].type * when the size is zero. PREREQUISITES * object is omitted by BIOS when the size is
drivers/platform/x86/hp/hp-bioscfg/order-list-attributes.c +2 -2
@@ -207,7 +207,7 @@ static int hp_populate_ordered_list_elements_from_package(union acpi_object *ordpr_warn ("Prerequisites size value exceeded the maximum number of elements supported or data may be malformed\n" );/* -* This HACK is needed to keep the expected +* This step is needed to keep the expected * element list pointing to the right obj[elem].type * when the size is zero. PREREQUISITES * object is omitted by BIOS when the size is
@@ -245,7 +245,7 @@ static int hp_populate_ordered_list_elements_from_package(union acpi_object *ordif (int_value >MAX_ELEMENTS_SIZE )pr_warn ("Ordered List size value exceeded the maximum number of elements supported or data may be malformed\n" );/* -* This HACK is needed to keep the expected +* This step is needed to keep the expected * element list pointing to the right obj[elem].type * when the size is zero. ORD_LIST_ELEMENTS * object is omitted by BIOS when the size is
drivers/platform/x86/hp/hp-bioscfg/passwdobj-attributes.c +2 -2
@@ -293,7 +293,7 @@ static int hp_populate_password_elements_from_package(union acpi_object *passworif (int_value >MAX_PREREQUISITES_SIZE )pr_warn ("Prerequisites size value exceeded the maximum number of elements supported or data may be malformed\n" ); -/* This HACK is needed to keep the expected +/* This step is needed to keep the expected * element list pointing to the right obj[elem].type * when the size is zero. PREREQUISITES * object is omitted by BIOS when the size is
@@ -337,7 +337,7 @@ static int hp_populate_password_elements_from_package(union acpi_object *passworif (int_value >MAX_ENCODINGS_SIZE )pr_warn ("Password Encoding size value exceeded the maximum number of elements supported or data may be malformed\n" ); -/* This HACK is needed to keep the expected +/* This step is needed to keep the expected * element list pointing to the right obj[elem].type * when the size is zero. PSWD_ENCODINGS * object is omitted by BIOS when the size is
drivers/platform/x86/hp/hp-bioscfg/string-attributes.c +1 -1
@@ -203,7 +203,7 @@ static int hp_populate_string_elements_from_package(union acpi_object *string_obif (string_data->common.prerequisites_size >MAX_PREREQUISITES_SIZE )pr_warn ("Prerequisites size value exceeded the maximum number of elements supported or data may be malformed\n" );/* -* This HACK is needed to keep the expected +* This step is needed to keep the expected * element list pointing to the right obj[elem].type * when the size is zero. PREREQUISITES * object is omitted by BIOS when the size is
Signature · 1 line
2.34.1
PATCH 4/8 hp-bioscfg: Change how prerequisites size is evaluated
In reply to Jorge LopezUpdate steps taken to evaluate prerequisites size value
---
Based on the latest platform-drivers-x86.git/for-next
--- drivers/platform/x86/hp/hp-bioscfg/enum-attributes.c | 6 ++++-- drivers/platform/x86/hp/hp-bioscfg/int-attributes.c | 6 +++++- drivers/platform/x86/hp/hp-bioscfg/order-list-attributes.c | 6 ++++-- drivers/platform/x86/hp/hp-bioscfg/passwdobj-attributes.c | 6 ++++-- drivers/platform/x86/hp/hp-bioscfg/string-attributes.c | 6 ++++-- 5 files changed, 21 insertions(+), 9 deletions(-)
drivers/platform/x86/hp/hp-bioscfg/enum-attributes.c +4 -2
@@ -190,9 +190,11 @@ static int hp_populate_enumeration_elements_from_package(union acpi_object *enum enum_data->common.sequence = int_value;break ;case PREREQUISITES_SIZE : - enum_data->common.prerequisites_size = int_value; -if (int_value >MAX_PREREQUISITES_SIZE ) +if (int_value >MAX_PREREQUISITES_SIZE ) {pr_warn ("Prerequisites size value exceeded the maximum number of elements supported or data may be malformed\n" ); + int_value =MAX_PREREQUISITES_SIZE ; + } + enum_data->common.prerequisites_size = int_value;/* * This step is needed to keep the expected
drivers/platform/x86/hp/hp-bioscfg/int-attributes.c +5 -1
@@ -208,8 +208,12 @@ static int hp_populate_integer_elements_from_package(union acpi_object *integer_ integer_data->common.sequence = int_value;break ;case PREREQUISITES_SIZE : -if (integer_data->common.prerequisites_size >MAX_PREREQUISITES_SIZE ) +if (int_value >MAX_PREREQUISITES_SIZE ) {pr_warn ("Prerequisites size value exceeded the maximum number of elements supported or data may be malformed\n" ); + int_value =MAX_PREREQUISITES_SIZE ; + } + integer_data->common.prerequisites_size = int_value; +/* * This step is needed to keep the expected * element list pointing to the right obj[elem].type
drivers/platform/x86/hp/hp-bioscfg/order-list-attributes.c +4 -2
@@ -202,9 +202,11 @@ static int hp_populate_ordered_list_elements_from_package(union acpi_object *ord ordered_list_data->common.sequence = int_value;break ;case PREREQUISITES_SIZE : - ordered_list_data->common.prerequisites_size = int_value; -if (int_value >MAX_PREREQUISITES_SIZE ) +if (int_value >MAX_PREREQUISITES_SIZE ) {pr_warn ("Prerequisites size value exceeded the maximum number of elements supported or data may be malformed\n" ); + int_value =MAX_PREREQUISITES_SIZE ; + } + ordered_list_data->common.prerequisites_size = int_value;/* * This step is needed to keep the expected
drivers/platform/x86/hp/hp-bioscfg/passwdobj-attributes.c +4 -2
@@ -289,9 +289,11 @@ static int hp_populate_password_elements_from_package(union acpi_object *passwor password_data->common.sequence = int_value;break ;case PREREQUISITES_SIZE : - password_data->common.prerequisites_size = int_value; -if (int_value >MAX_PREREQUISITES_SIZE ) +if (int_value >MAX_PREREQUISITES_SIZE ) {pr_warn ("Prerequisites size value exceeded the maximum number of elements supported or data may be malformed\n" ); + int_value =MAX_PREREQUISITES_SIZE ; + } + password_data->common.prerequisites_size = int_value;/* This step is needed to keep the expected * element list pointing to the right obj[elem].type
drivers/platform/x86/hp/hp-bioscfg/string-attributes.c +4 -2
@@ -198,10 +198,12 @@ static int hp_populate_string_elements_from_package(union acpi_object *string_ob string_data->common.sequence = int_value;break ;case PREREQUISITES_SIZE : +if (int_value >MAX_PREREQUISITES_SIZE ) { +pr_warn ("Prerequisites size value exceeded the maximum number of elements supported or data may be malformed\n" ); + int_value =MAX_PREREQUISITES_SIZE ; + } string_data->common.prerequisites_size = int_value; -if (string_data->common.prerequisites_size >MAX_PREREQUISITES_SIZE ) -pr_warn ("Prerequisites size value exceeded the maximum number of elements supported or data may be malformed\n" );/* * This step is needed to keep the expected * element list pointing to the right obj[elem].type
Signature · 1 line
2.34.1
PATCH 5/8 hp-bioscfg: Change how order list size is evaluated
In reply to Jorge LopezUpdate steps how order list size is evaluated
---
Based on the latest platform-drivers-x86.git/for-next
--- drivers/platform/x86/hp/hp-bioscfg/order-list-attributes.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/platform/x86/hp/hp-bioscfg/order-list-attributes.c +5 -2
@@ -243,9 +243,12 @@ static int hp_populate_ordered_list_elements_from_package(union acpi_object *ordbreak ;case ORD_LIST_SIZE : +if (int_value >MAX_ELEMENTS_SIZE ) { +pr_warn ("Order List size value exceeded the maximum number of elements supported or data may be malformed\n" ); + int_value =MAX_ELEMENTS_SIZE ; + } ordered_list_data->elements_size = int_value; -if (int_value >MAX_ELEMENTS_SIZE ) -pr_warn ("Ordered List size value exceeded the maximum number of elements supported or data may be malformed\n" ); +/* * This step is needed to keep the expected * element list pointing to the right obj[elem].type
Signature · 1 line
2.34.1
PATCH 6/8 hp-bioscfg: Change how enum possible values size is evaluated
In reply to Jorge LopezUpdates steps how enum possible values size is evaluated
---
Based on the latest platform-drivers-x86.git/for-next
--- drivers/platform/x86/hp/hp-bioscfg/enum-attributes.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/platform/x86/hp/hp-bioscfg/enum-attributes.c +4 -2
@@ -240,9 +240,11 @@ static int hp_populate_enumeration_elements_from_package(union acpi_object *enum str_value, sizeof(enum_data->current_value));break ;case ENUM_SIZE : - enum_data->possible_values_size = int_value; -if (int_value >MAX_VALUES_SIZE ) +if (int_value >MAX_VALUES_SIZE ) {pr_warn ("Possible number values size value exceeded the maximum number of elements supported or data may be malformed\n" ); + int_value =MAX_VALUES_SIZE ; + } + enum_data->possible_values_size = int_value;/* * This step is needed to keep the expected
Signature · 1 line
2.34.1
PATCH 7/8 hp-bioscfg: Change how password encoding size is evaluated
In reply to Jorge LopezUpdate steps how password encoding size is evaluated
---
Based on the latest platform-drivers-x86.git/for-next
--- drivers/platform/x86/hp/hp-bioscfg/passwdobj-attributes.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/platform/x86/hp/hp-bioscfg/passwdobj-attributes.c +5 -2
@@ -335,9 +335,12 @@ static int hp_populate_password_elements_from_package(union acpi_object *passwor password_data->max_password_length = int_value;break ;case PSWD_SIZE : - password_data->encodings_size = int_value; -if (int_value >MAX_ENCODINGS_SIZE ) + +if (int_value >MAX_ENCODINGS_SIZE ) {pr_warn ("Password Encoding size value exceeded the maximum number of elements supported or data may be malformed\n" ); + int_value =MAX_ENCODINGS_SIZE ; + } + password_data->encodings_size = int_value;/* This step is needed to keep the expected * element list pointing to the right obj[elem].type
Signature · 1 line
2.34.1
PATCH 8/8 hp-bioscfg: Remove duplicate use of variable in inner loop
In reply to Jorge LopezReplace use of same variable in inner loop.
---
Based on the latest platform-drivers-x86.git/for-next
--- .../x86/hp/hp-bioscfg/order-list-attributes.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-)
drivers/platform/x86/hp/hp-bioscfg/order-list-attributes.c +5 -7
@@ -136,6 +136,7 @@ static int hp_populate_ordered_list_elements_from_package(union acpi_object *ordu32 size;u32 int_value =0 ;int elem; +int olist_elem;int reqs;int eloc;char *tmpstr =NULL ;
@@ -147,10 +148,7 @@ static int hp_populate_ordered_list_elements_from_package(union acpi_object *ordif (!order_obj)return -EINVAL ; -for (elem =1 , eloc =1 ; elem < order_obj_count; elem++, eloc++) { -/* ONLY look at the first ORDERED_ELEM_CNT elements */ -if (eloc ==ORD_ELEM_CNT ) - goto exit_list; +for (elem =1 , eloc =1 ; eloc <ORD_ELEM_CNT ; elem++, eloc++) {switch (order_obj[elem].type) {case ACPI_TYPE_STRING :
@@ -277,10 +275,10 @@ static int hp_populate_ordered_list_elements_from_package(union acpi_object *ord tmpstr, sizeof(ordered_list_data->elements[0])); -for (elem =1 ; elem <MAX_ELEMENTS_SIZE && part; elem++) { -strscpy (ordered_list_data->elements[elem], +for (olist_elem =1 ; olist_elem <MAX_ELEMENTS_SIZE && part; olist_elem++) { +strscpy (ordered_list_data->elements[olist_elem], part, -sizeof (ordered_list_data->elements[elem])); +sizeof (ordered_list_data->elements[olist_elem])); part =strsep (&part_tmp,SEMICOLON_SEP ); }
Signature · 1 line
2.34.1
These are fine. We still need to do something like this. Also we could just get rid of value_len completely. Nothing uses it.
drivers/platform/x86/hp/hp-bioscfg/order-list-attributes.c +1 -1
@@ -264,7 +264,7 @@ static int hp_populate_ordered_list_elements_from_package(union acpi_object *ord* Ordered list data is stored in hex and comma separated format * Convert the data and split it to show each element */ - ret =hp_convert_hexstr_to_str (str_value, value_len, &tmpstr, &tmp_len); + ret =hp_convert_hexstr_to_str (str_value, size, &tmpstr, &tmp_len);if (ret) goto exit_list;
I will submit a new patch replacing 'value_len' for 'size' in line 267 as indicated.
'value_len' is utilized earlier in the code so we cannot remove it completely from the function.
Quoted 17 lines · Dan Carpenter
These are fine. We still need to do something like this. Also we could just get rid of
value_lencompletely. Nothing uses it.drivers/platform/x86/hp/hp-bioscfg/order-list-attributes.c +1
-1@@ -264,7 +264,7 @@ static int hp_populate_ordered_list_elements_from_package(union acpi_object *ord* Ordered list data is stored in hex and comma separated format * Convert the data and split it to show each element */ - ret =hp_convert_hexstr_to_str (str_value, value_len, &tmpstr, &tmp_len); + ret =hp_convert_hexstr_to_str (str_value, size, &tmpstr, &tmp_len);if (ret) goto exit_list;
Quoted 5 lines · Jorge Lopez
I will submit a new patch replacing '
value_len' for 'size' in line 267 as indicated.
'value_len' is utilized earlier in the code so we cannot remove it completely from the function.
After replacing size then it looks like this.
$ grep value_len drivers/platform/x86/hp/hp-bioscfg/order-list-attributes.c
int value_len = 0;
&str_value, &value_len);
&str_value, &value_len);It's a write only variable.
regards,
dan carpenter
Ok. Thanks for the clarification. I will remove 'value_len' and replace all its references with 'size'.
Quoted 20 lines · Dan Carpenter
Quoted 5 lines · Jorge Lopez
I will submit a new patch replacing '
value_len' for 'size' in line 267 as indicated.
'value_len' is utilized earlier in the code so we cannot remove it completely from the function.After replacing size then it looks like this.
$ grep value_len drivers/platform/x86/hp/hp-bioscfg/order-list-attributes.c int value_len = 0; &str_value, &value_len); &str_value, &value_len);It's a write only variable.
regards,
dan carpenter
Quoted 2 lines · Jorge Lopez
Ok. Thanks for the clarification. I will remove '
value_len' and replace all its references with 'size'.
Ugh... No, that's worse than the original. Just leave value_len as is in that case. :P
regards,
dan carpenter
Hi,
Quoted 17 lines · Jorge Lopez
Submit individual patches to address memory leaks and uninitialized variable errors.
Addressed several review comments making the source code more readable. Removed duplicate use of variable in inner loop.Changes were tested with a HP EliteBook x360 1030 G3
Jorge Lopez (8):
hp-bioscfg: Fix memory leaks in attribute packages
hp-bioscfg: Fix uninitialized variable errors
hp-bioscfg: Replace the word HACK from source code
hp-bioscfg: Change how prerequisites size is evaluated
hp-bioscfg: Change how order list size is evaluated
hp-bioscfg: Change how enum possible values size is evaluated
hp-bioscfg: Change how password encoding size is evaluated
hp-bioscfg: Remove duplicate use of variable in inner loop
Quoted 6 lines
.../x86/hp/hp-bioscfg/enum-attributes.c | 24 ++++++++---- .../x86/hp/hp-bioscfg/int-attributes.c | 15 +++++-- .../x86/hp/hp-bioscfg/order-list-attributes.c | 39 ++++++++++++------- .../x86/hp/hp-bioscfg/passwdobj-attributes.c | 27 +++++++++---- .../x86/hp/hp-bioscfg/string-attributes.c | 13 +++++-- 5 files changed, 82 insertions(+), 36 deletions(-)
Thank you for your patch-series, I've applied the series to my review-hans branch:
https://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86.git/log/?h=review-hans
Note it will show up in my review-hans branch once I've pushed my local branch there, which might take a while.
Once I've run some tests on this branch the patches there will be added to the platform-drivers-x86/for-next branch and eventually will be included in the pdx86 pull-request to Linus for the next merge-window.
Regards,
Hans