Skip to content

Commit

Permalink
platform/x86: hp-bioscfg: Change how prerequisites size is evaluated
Browse files Browse the repository at this point in the history
Update steps taken to evaluate prerequisites size value

Signed-off-by: Jorge Lopez <jorge.lopez2@hp.com>
Link: https://lore.kernel.org/r/20230731203141.30044-5-jorge.lopez2@hp.com
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
  • Loading branch information
Jorge Lopez authored and jwrdegoede committed Aug 7, 2023
1 parent a585400 commit 08f1f21
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 9 deletions.
6 changes: 4 additions & 2 deletions drivers/platform/x86/hp/hp-bioscfg/enum-attributes.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 5 additions & 1 deletion drivers/platform/x86/hp/hp-bioscfg/int-attributes.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 4 additions & 2 deletions drivers/platform/x86/hp/hp-bioscfg/order-list-attributes.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 4 additions & 2 deletions drivers/platform/x86/hp/hp-bioscfg/passwdobj-attributes.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 4 additions & 2 deletions drivers/platform/x86/hp/hp-bioscfg/string-attributes.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 08f1f21

Please sign in to comment.