mirror of
https://github.com/torvalds/linux.git
synced 2026-06-06 13:37:36 +02:00
platform/x86: hp: hp-bioscfg: Use 2-argument strscpy()
Use 2-argument strscpy(), which is not only shorter but also provides an additional check that destination buffer is an array. Signed-off-by: Andy Shevchenko <andy.shevchenko@gmail.com> Link: https://lore.kernel.org/r/20240602090244.1666360-3-andy.shevchenko@gmail.com Reviewed-by: Hans de Goede <hdegoede@redhat.com> Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
This commit is contained in:
parent
057e025a4f
commit
c5288cda69
|
|
@ -52,9 +52,7 @@ static void update_enumeration_value(int instance_id, char *attr_value)
|
|||
{
|
||||
struct enumeration_data *enum_data = &bioscfg_drv.enumeration_data[instance_id];
|
||||
|
||||
strscpy(enum_data->current_value,
|
||||
attr_value,
|
||||
sizeof(enum_data->current_value));
|
||||
strscpy(enum_data->current_value, attr_value);
|
||||
}
|
||||
|
||||
ATTRIBUTE_S_COMMON_PROPERTY_SHOW(display_name, enumeration);
|
||||
|
|
@ -174,8 +172,7 @@ static int hp_populate_enumeration_elements_from_package(union acpi_object *enum
|
|||
case VALUE:
|
||||
break;
|
||||
case PATH:
|
||||
strscpy(enum_data->common.path, str_value,
|
||||
sizeof(enum_data->common.path));
|
||||
strscpy(enum_data->common.path, str_value);
|
||||
break;
|
||||
case IS_READONLY:
|
||||
enum_data->common.is_readonly = int_value;
|
||||
|
|
@ -222,9 +219,7 @@ static int hp_populate_enumeration_elements_from_package(union acpi_object *enum
|
|||
if (ret)
|
||||
return -EINVAL;
|
||||
|
||||
strscpy(enum_data->common.prerequisites[reqs],
|
||||
str_value,
|
||||
sizeof(enum_data->common.prerequisites[reqs]));
|
||||
strscpy(enum_data->common.prerequisites[reqs], str_value);
|
||||
|
||||
kfree(str_value);
|
||||
str_value = NULL;
|
||||
|
|
@ -236,8 +231,7 @@ static int hp_populate_enumeration_elements_from_package(union acpi_object *enum
|
|||
break;
|
||||
|
||||
case ENUM_CURRENT_VALUE:
|
||||
strscpy(enum_data->current_value,
|
||||
str_value, sizeof(enum_data->current_value));
|
||||
strscpy(enum_data->current_value, str_value);
|
||||
break;
|
||||
case ENUM_SIZE:
|
||||
if (int_value > MAX_VALUES_SIZE) {
|
||||
|
|
@ -278,9 +272,7 @@ static int hp_populate_enumeration_elements_from_package(union acpi_object *enum
|
|||
* is greater than MAX_VALUES_SIZE
|
||||
*/
|
||||
if (size < MAX_VALUES_SIZE)
|
||||
strscpy(enum_data->possible_values[pos_values],
|
||||
str_value,
|
||||
sizeof(enum_data->possible_values[pos_values]));
|
||||
strscpy(enum_data->possible_values[pos_values], str_value);
|
||||
|
||||
kfree(str_value);
|
||||
str_value = NULL;
|
||||
|
|
|
|||
|
|
@ -192,8 +192,7 @@ static int hp_populate_integer_elements_from_package(union acpi_object *integer_
|
|||
integer_data->current_value = int_value;
|
||||
break;
|
||||
case PATH:
|
||||
strscpy(integer_data->common.path, str_value,
|
||||
sizeof(integer_data->common.path));
|
||||
strscpy(integer_data->common.path, str_value);
|
||||
break;
|
||||
case IS_READONLY:
|
||||
integer_data->common.is_readonly = int_value;
|
||||
|
|
@ -240,9 +239,7 @@ static int hp_populate_integer_elements_from_package(union acpi_object *integer_
|
|||
if (ret)
|
||||
continue;
|
||||
|
||||
strscpy(integer_data->common.prerequisites[reqs],
|
||||
str_value,
|
||||
sizeof(integer_data->common.prerequisites[reqs]));
|
||||
strscpy(integer_data->common.prerequisites[reqs], str_value);
|
||||
kfree(str_value);
|
||||
str_value = NULL;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -57,9 +57,7 @@ static void update_ordered_list_value(int instance, char *attr_value)
|
|||
{
|
||||
struct ordered_list_data *ordered_list_data = &bioscfg_drv.ordered_list_data[instance];
|
||||
|
||||
strscpy(ordered_list_data->current_value,
|
||||
attr_value,
|
||||
sizeof(ordered_list_data->current_value));
|
||||
strscpy(ordered_list_data->current_value, attr_value);
|
||||
}
|
||||
|
||||
ATTRIBUTE_S_COMMON_PROPERTY_SHOW(display_name, ordered_list);
|
||||
|
|
@ -179,13 +177,11 @@ static int hp_populate_ordered_list_elements_from_package(union acpi_object *ord
|
|||
/* Assign appropriate element value to corresponding field*/
|
||||
switch (eloc) {
|
||||
case VALUE:
|
||||
strscpy(ordered_list_data->current_value,
|
||||
str_value, sizeof(ordered_list_data->current_value));
|
||||
strscpy(ordered_list_data->current_value, str_value);
|
||||
replace_char_str(ordered_list_data->current_value, COMMA_SEP, SEMICOLON_SEP);
|
||||
break;
|
||||
case PATH:
|
||||
strscpy(ordered_list_data->common.path, str_value,
|
||||
sizeof(ordered_list_data->common.path));
|
||||
strscpy(ordered_list_data->common.path, str_value);
|
||||
break;
|
||||
case IS_READONLY:
|
||||
ordered_list_data->common.is_readonly = int_value;
|
||||
|
|
@ -227,9 +223,7 @@ static int hp_populate_ordered_list_elements_from_package(union acpi_object *ord
|
|||
if (ret)
|
||||
continue;
|
||||
|
||||
strscpy(ordered_list_data->common.prerequisites[reqs],
|
||||
str_value,
|
||||
sizeof(ordered_list_data->common.prerequisites[reqs]));
|
||||
strscpy(ordered_list_data->common.prerequisites[reqs], str_value);
|
||||
|
||||
kfree(str_value);
|
||||
str_value = NULL;
|
||||
|
|
@ -271,9 +265,7 @@ static int hp_populate_ordered_list_elements_from_package(union acpi_object *ord
|
|||
part = strsep(&part_tmp, COMMA_SEP);
|
||||
|
||||
for (olist_elem = 0; olist_elem < MAX_ELEMENTS_SIZE && part; olist_elem++) {
|
||||
strscpy(ordered_list_data->elements[olist_elem],
|
||||
part,
|
||||
sizeof(ordered_list_data->elements[olist_elem]));
|
||||
strscpy(ordered_list_data->elements[olist_elem], part);
|
||||
part = strsep(&part_tmp, COMMA_SEP);
|
||||
}
|
||||
ordered_list_data->elements_size = olist_elem;
|
||||
|
|
|
|||
|
|
@ -101,13 +101,9 @@ static int store_password_instance(struct kobject *kobj, const char *buf,
|
|||
|
||||
if (!ret) {
|
||||
if (is_current)
|
||||
strscpy(bioscfg_drv.password_data[id].current_password,
|
||||
buf_cp,
|
||||
sizeof(bioscfg_drv.password_data[id].current_password));
|
||||
strscpy(bioscfg_drv.password_data[id].current_password, buf_cp);
|
||||
else
|
||||
strscpy(bioscfg_drv.password_data[id].new_password,
|
||||
buf_cp,
|
||||
sizeof(bioscfg_drv.password_data[id].new_password));
|
||||
strscpy(bioscfg_drv.password_data[id].new_password, buf_cp);
|
||||
}
|
||||
|
||||
kfree(buf_cp);
|
||||
|
|
@ -272,8 +268,7 @@ static int hp_populate_password_elements_from_package(union acpi_object *passwor
|
|||
case VALUE:
|
||||
break;
|
||||
case PATH:
|
||||
strscpy(password_data->common.path, str_value,
|
||||
sizeof(password_data->common.path));
|
||||
strscpy(password_data->common.path, str_value);
|
||||
break;
|
||||
case IS_READONLY:
|
||||
password_data->common.is_readonly = int_value;
|
||||
|
|
@ -315,9 +310,7 @@ static int hp_populate_password_elements_from_package(union acpi_object *passwor
|
|||
if (ret)
|
||||
break;
|
||||
|
||||
strscpy(password_data->common.prerequisites[reqs],
|
||||
str_value,
|
||||
sizeof(password_data->common.prerequisites[reqs]));
|
||||
strscpy(password_data->common.prerequisites[reqs], str_value);
|
||||
|
||||
kfree(str_value);
|
||||
str_value = NULL;
|
||||
|
|
@ -359,9 +352,7 @@ static int hp_populate_password_elements_from_package(union acpi_object *passwor
|
|||
if (ret)
|
||||
break;
|
||||
|
||||
strscpy(password_data->encodings[pos_values],
|
||||
str_value,
|
||||
sizeof(password_data->encodings[pos_values]));
|
||||
strscpy(password_data->encodings[pos_values], str_value);
|
||||
kfree(str_value);
|
||||
str_value = NULL;
|
||||
|
||||
|
|
|
|||
|
|
@ -365,8 +365,7 @@ int hp_populate_secure_platform_data(struct kobject *attr_name_kobj)
|
|||
/* Populate data for Secure Platform Management */
|
||||
bioscfg_drv.spm_data.attr_name_kobj = attr_name_kobj;
|
||||
|
||||
strscpy(bioscfg_drv.spm_data.attribute_name, SPM_STR,
|
||||
sizeof(bioscfg_drv.spm_data.attribute_name));
|
||||
strscpy(bioscfg_drv.spm_data.attribute_name, SPM_STR);
|
||||
|
||||
bioscfg_drv.spm_data.is_enabled = 0;
|
||||
bioscfg_drv.spm_data.mechanism = 0;
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ static void update_string_value(int instance_id, char *attr_value)
|
|||
struct string_data *string_data = &bioscfg_drv.string_data[instance_id];
|
||||
|
||||
/* Write settings to BIOS */
|
||||
strscpy(string_data->current_value, attr_value, sizeof(string_data->current_value));
|
||||
strscpy(string_data->current_value, attr_value);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
@ -178,12 +178,10 @@ static int hp_populate_string_elements_from_package(union acpi_object *string_ob
|
|||
/* Assign appropriate element value to corresponding field*/
|
||||
switch (eloc) {
|
||||
case VALUE:
|
||||
strscpy(string_data->current_value,
|
||||
str_value, sizeof(string_data->current_value));
|
||||
strscpy(string_data->current_value, str_value);
|
||||
break;
|
||||
case PATH:
|
||||
strscpy(string_data->common.path, str_value,
|
||||
sizeof(string_data->common.path));
|
||||
strscpy(string_data->common.path, str_value);
|
||||
break;
|
||||
case IS_READONLY:
|
||||
string_data->common.is_readonly = int_value;
|
||||
|
|
@ -231,9 +229,7 @@ static int hp_populate_string_elements_from_package(union acpi_object *string_ob
|
|||
if (ret)
|
||||
continue;
|
||||
|
||||
strscpy(string_data->common.prerequisites[reqs],
|
||||
str_value,
|
||||
sizeof(string_data->common.prerequisites[reqs]));
|
||||
strscpy(string_data->common.prerequisites[reqs], str_value);
|
||||
kfree(str_value);
|
||||
str_value = NULL;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user