platform/x86: hp-bioscfg: Fix memory leaks in attribute packages
Address memory leaks while handling elements in packages. Signed-off-by: Jorge Lopez <jorge.lopez2@hp.com> Link: https://lore.kernel.org/r/20230731203141.30044-2-jorge.lopez2@hp.com Reviewed-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
This commit is contained in:
parent
b0bfa7972b
commit
467d416381
@ -164,6 +164,7 @@ static int hp_populate_enumeration_elements_from_package(union acpi_object *enum
|
||||
if (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 *enum
|
||||
strscpy(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:
|
||||
|
@ -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);
|
||||
|
@ -174,6 +174,7 @@ static int hp_populate_ordered_list_elements_from_package(union acpi_object *ord
|
||||
if (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:
|
||||
|
@ -264,6 +264,7 @@ static int hp_populate_password_elements_from_package(union acpi_object *passwor
|
||||
if (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 *passwor
|
||||
pr_warn("Invalid element: %d found in Password attribute or data may be malformed\n", elem);
|
||||
break;
|
||||
}
|
||||
|
||||
kfree(str_value);
|
||||
str_value = NULL;
|
||||
}
|
||||
|
||||
exit_package:
|
||||
|
@ -171,6 +171,7 @@ static int hp_populate_string_elements_from_package(union acpi_object *string_ob
|
||||
if (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:
|
||||
|
Loading…
x
Reference in New Issue
Block a user