Skip to contentSkip to conversation

platform/x86: dell-wmi-sysman: Make populate_foo_data functions more robust

PATCH Superseded Prasanth KSR 3 participants 3 messages Apr 27, 2021 – May 11, 2021

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 platform/x86: dell-wmi-sysman: Make populate_foo_data functions more robust

1. Check acpi type before assignment of each property value

2. Add boundary check for properties count

---
 .../dell/dell-wmi-sysman/dell-wmi-sysman.h    |  5 ++-
 .../dell/dell-wmi-sysman/enum-attributes.c    | 36 ++++++++++++++++---
 .../x86/dell/dell-wmi-sysman/int-attributes.c | 16 +++++++++
 .../dell/dell-wmi-sysman/passobj-attributes.c |  6 ++++
 .../dell/dell-wmi-sysman/string-attributes.c  | 16 ++++++++-
 .../x86/dell/dell-wmi-sysman/sysman.c         | 17 ++++++---
 6 files changed, 84 insertions(+), 12 deletions(-)
drivers/platform/x86/dell/dell-wmi-sysman/dell-wmi-sysman.h +4 -1
index b80f2a62ea3f..3ad33a094588 100644
@@ -152,12 +152,15 @@ static ssize_t curr_val##_store(struct kobject *kobj,				\
 	return ret ? ret : count;						\
 }
 
+#define check_property_type(attr, prop, valuetype)				\
+	(attr##_obj[prop].type != valuetype)
+
 union acpi_object *get_wmiobj_pointer(int instance_id, const char *guid_string);
 int get_instance_count(const char *guid_string);
 void strlcpy_attr(char *dest, char *src);
 
 int populate_enum_data(union acpi_object *enumeration_obj, int instance_id,
-			struct kobject *attr_name_kobj);
+			struct kobject *attr_name_kobj, u32 enum_property_count);
 int alloc_enum_data(void);
 void exit_enum_attributes(void);
 
drivers/platform/x86/dell/dell-wmi-sysman/enum-attributes.c +31 -5
index 091e48c217ed..70f4ace56ec3 100644
@@ -132,39 +132,65 @@ int alloc_enum_data(void)
  * @enumeration_obj: ACPI object with enumeration data
  * @instance_id: The instance to enumerate
  * @attr_name_kobj: The parent kernel object
+ * @enum_property_count: Total properties count under enumeration type
  */
 int populate_enum_data(union acpi_object *enumeration_obj, int instance_id,
-			struct kobject *attr_name_kobj)
+			struct kobject *attr_name_kobj, u32 enum_property_count)
 {
 	int i, next_obj, value_modifier_count, possible_values_count;
 
 	wmi_priv.enumeration_data[instance_id].attr_name_kobj = attr_name_kobj;
+	if (check_property_type(enumeration, ATTR_NAME, ACPI_TYPE_STRING))
+		return -EINVAL;
 	strlcpy_attr(wmi_priv.enumeration_data[instance_id].attribute_name,
 		enumeration_obj[ATTR_NAME].string.pointer);
+	if (check_property_type(enumeration, DISPL_NAME_LANG_CODE, ACPI_TYPE_STRING))
+		return -EINVAL;
 	strlcpy_attr(wmi_priv.enumeration_data[instance_id].display_name_language_code,
 		enumeration_obj[DISPL_NAME_LANG_CODE].string.pointer);
+	if (check_property_type(enumeration, DISPLAY_NAME, ACPI_TYPE_STRING))
+		return -EINVAL;
 	strlcpy_attr(wmi_priv.enumeration_data[instance_id].display_name,
 		enumeration_obj[DISPLAY_NAME].string.pointer);
+	if (check_property_type(enumeration, DEFAULT_VAL, ACPI_TYPE_STRING))
+		return -EINVAL;
 	strlcpy_attr(wmi_priv.enumeration_data[instance_id].default_value,
 		enumeration_obj[DEFAULT_VAL].string.pointer);
+	if (check_property_type(enumeration, MODIFIER, ACPI_TYPE_STRING))
+		return -EINVAL;
 	strlcpy_attr(wmi_priv.enumeration_data[instance_id].dell_modifier,
 		enumeration_obj[MODIFIER].string.pointer);
 
 	next_obj = MODIFIER + 1;
 
-	value_modifier_count = (uintptr_t)enumeration_obj[next_obj].string.pointer;
+	if (next_obj >= enum_property_count)
+		return -EINVAL;
+
+	if (check_property_type(enumeration, next_obj, ACPI_TYPE_INTEGER))
+		return -EINVAL;
+	value_modifier_count = (uintptr_t)enumeration_obj[next_obj++].string.pointer;
 
 	for (i = 0; i < value_modifier_count; i++) {
+		if (next_obj >= enum_property_count)
+			return -EINVAL;
+		if (check_property_type(enumeration, next_obj, ACPI_TYPE_STRING))
+			return -EINVAL;
 		strcat(wmi_priv.enumeration_data[instance_id].dell_value_modifier,
-			enumeration_obj[++next_obj].string.pointer);
+			enumeration_obj[next_obj++].string.pointer);
 		strcat(wmi_priv.enumeration_data[instance_id].dell_value_modifier, ";");
 	}
 
-	possible_values_count = (uintptr_t) enumeration_obj[++next_obj].string.pointer;
+	if (check_property_type(enumeration, next_obj, ACPI_TYPE_INTEGER))
+		return -EINVAL;
+	possible_values_count = (uintptr_t) enumeration_obj[next_obj++].string.pointer;
 
 	for (i = 0; i < possible_values_count; i++) {
+		if (next_obj >= enum_property_count)
+			return -EINVAL;
+		if (check_property_type(enumeration, next_obj, ACPI_TYPE_STRING))
+			return -EINVAL;
 		strcat(wmi_priv.enumeration_data[instance_id].possible_values,
-			enumeration_obj[++next_obj].string.pointer);
+			enumeration_obj[next_obj++].string.pointer);
 		strcat(wmi_priv.enumeration_data[instance_id].possible_values, ";");
 	}
 
drivers/platform/x86/dell/dell-wmi-sysman/int-attributes.c +16 -0
index 8a49ba6e44f9..951e75b538fa 100644
@@ -141,20 +141,36 @@ int populate_int_data(union acpi_object *integer_obj, int instance_id,
 			struct kobject *attr_name_kobj)
 {
 	wmi_priv.integer_data[instance_id].attr_name_kobj = attr_name_kobj;
+	if (check_property_type(integer, ATTR_NAME, ACPI_TYPE_STRING))
+		return -EINVAL;
 	strlcpy_attr(wmi_priv.integer_data[instance_id].attribute_name,
 		integer_obj[ATTR_NAME].string.pointer);
+	if (check_property_type(integer, DISPL_NAME_LANG_CODE, ACPI_TYPE_STRING))
+		return -EINVAL;
 	strlcpy_attr(wmi_priv.integer_data[instance_id].display_name_language_code,
 		integer_obj[DISPL_NAME_LANG_CODE].string.pointer);
+	if (check_property_type(integer, DISPLAY_NAME, ACPI_TYPE_STRING))
+		return -EINVAL;
 	strlcpy_attr(wmi_priv.integer_data[instance_id].display_name,
 		integer_obj[DISPLAY_NAME].string.pointer);
+	if (check_property_type(integer, DEFAULT_VAL, ACPI_TYPE_INTEGER))
+		return -EINVAL;
 	wmi_priv.integer_data[instance_id].default_value =
 		(uintptr_t)integer_obj[DEFAULT_VAL].string.pointer;
+	if (check_property_type(integer, MODIFIER, ACPI_TYPE_STRING))
+		return -EINVAL;
 	strlcpy_attr(wmi_priv.integer_data[instance_id].dell_modifier,
 		integer_obj[MODIFIER].string.pointer);
+	if (check_property_type(integer, MIN_VALUE, ACPI_TYPE_INTEGER))
+		return -EINVAL;
 	wmi_priv.integer_data[instance_id].min_value =
 		(uintptr_t)integer_obj[MIN_VALUE].string.pointer;
+	if (check_property_type(integer, MAX_VALUE, ACPI_TYPE_INTEGER))
+		return -EINVAL;
 	wmi_priv.integer_data[instance_id].max_value =
 		(uintptr_t)integer_obj[MAX_VALUE].string.pointer;
+	if (check_property_type(integer, SCALAR_INCR, ACPI_TYPE_INTEGER))
+		return -EINVAL;
 	wmi_priv.integer_data[instance_id].scalar_increment =
 		(uintptr_t)integer_obj[SCALAR_INCR].string.pointer;
 
drivers/platform/x86/dell/dell-wmi-sysman/passobj-attributes.c +6 -0
index 834b3e82ad9f..230e6ee96636 100644
@@ -159,10 +159,16 @@ int alloc_po_data(void)
 int populate_po_data(union acpi_object *po_obj, int instance_id, struct kobject *attr_name_kobj)
 {
 	wmi_priv.po_data[instance_id].attr_name_kobj = attr_name_kobj;
+	if (check_property_type(po, ATTR_NAME, ACPI_TYPE_STRING))
+		return -EINVAL;
 	strlcpy_attr(wmi_priv.po_data[instance_id].attribute_name,
 		     po_obj[ATTR_NAME].string.pointer);
+	if (check_property_type(po, MIN_PASS_LEN, ACPI_TYPE_INTEGER))
+		return -EINVAL;
 	wmi_priv.po_data[instance_id].min_password_length =
 		(uintptr_t)po_obj[MIN_PASS_LEN].string.pointer;
+	if (check_property_type(po, MAX_PASS_LEN, ACPI_TYPE_INTEGER))
+		return -EINVAL;
 	wmi_priv.po_data[instance_id].max_password_length =
 		(uintptr_t) po_obj[MAX_PASS_LEN].string.pointer;
 
drivers/platform/x86/dell/dell-wmi-sysman/string-attributes.c +15 -1
index 552537852459..c392f0ecf8b5 100644
@@ -118,24 +118,38 @@ int alloc_str_data(void)
 
 /**
  * populate_str_data() - Populate all properties of an instance under string attribute
- * @str_obj: ACPI object with integer data
+ * @str_obj: ACPI object with string data
  * @instance_id: The instance to enumerate
  * @attr_name_kobj: The parent kernel object
  */
 int populate_str_data(union acpi_object *str_obj, int instance_id, struct kobject *attr_name_kobj)
 {
 	wmi_priv.str_data[instance_id].attr_name_kobj = attr_name_kobj;
+	if (check_property_type(str, ATTR_NAME, ACPI_TYPE_STRING))
+		return -EINVAL;
 	strlcpy_attr(wmi_priv.str_data[instance_id].attribute_name,
 		     str_obj[ATTR_NAME].string.pointer);
+	if (check_property_type(str, DISPL_NAME_LANG_CODE, ACPI_TYPE_STRING))
+		return -EINVAL;
 	strlcpy_attr(wmi_priv.str_data[instance_id].display_name_language_code,
 		     str_obj[DISPL_NAME_LANG_CODE].string.pointer);
+	if (check_property_type(str, DISPLAY_NAME, ACPI_TYPE_STRING))
+		return -EINVAL;
 	strlcpy_attr(wmi_priv.str_data[instance_id].display_name,
 		     str_obj[DISPLAY_NAME].string.pointer);
+	if (check_property_type(str, DEFAULT_VAL, ACPI_TYPE_STRING))
+		return -EINVAL;
 	strlcpy_attr(wmi_priv.str_data[instance_id].default_value,
 		     str_obj[DEFAULT_VAL].string.pointer);
+	if (check_property_type(str, MODIFIER, ACPI_TYPE_STRING))
+		return -EINVAL;
 	strlcpy_attr(wmi_priv.str_data[instance_id].dell_modifier,
 		     str_obj[MODIFIER].string.pointer);
+	if (check_property_type(str, MIN_LEN, ACPI_TYPE_INTEGER))
+		return -EINVAL;
 	wmi_priv.str_data[instance_id].min_length = (uintptr_t)str_obj[MIN_LEN].string.pointer;
+	if (check_property_type(str, MAX_LEN, ACPI_TYPE_INTEGER))
+		return -EINVAL;
 	wmi_priv.str_data[instance_id].max_length = (uintptr_t) str_obj[MAX_LEN].string.pointer;
 
 	return sysfs_create_group(attr_name_kobj, &str_attr_group);
drivers/platform/x86/dell/dell-wmi-sysman/sysman.c +12 -5
index c8d276d78e92..5276e8c5aad5 100644
@@ -412,10 +412,16 @@ static int init_bios_attributes(int attr_type, const char *guid)
 		return retval;
 
 	switch (attr_type) {
-	case ENUM:	min_elements = 8;	break;
-	case INT:	min_elements = 9;	break;
-	case STR:	min_elements = 8;	break;
-	case PO:	min_elements = 4;	break;
+	case ENUM:
+	case STR:
+		min_elements = 8;
+		break;
+	case INT:
+		min_elements = 9;
+		break;
+	case PO:
+		min_elements = 4;
+		break;
 	default:
 		pr_err("Error: Unknown attr_type: %d\n", attr_type);
 		return -EINVAL;
@@ -481,7 +487,8 @@ static int init_bios_attributes(int attr_type, const char *guid)
 		/* enumerate all of this attribute */
 		switch (attr_type) {
 		case ENUM:
-			retval = populate_enum_data(elements, instance_id, attr_name_kobj);
+			retval = populate_enum_data(elements, instance_id, attr_name_kobj,
+					obj->package.count);
 			break;
 		case INT:
 			retval = populate_int_data(elements, instance_id, attr_name_kobj);
Signature · 1 line
2.25.1
#1 lore raw

Hi,

Quoted 7 lines · Prasanth KSR

1. Check acpi type before assignment of each property value

2. Add boundary check for properties count

Thanks this mostly looks good, 2 small remarks inline below.

Once those are fixed this is ready for merging.

Quoted 80 lines
---
 .../dell/dell-wmi-sysman/dell-wmi-sysman.h    |  5 ++-
 .../dell/dell-wmi-sysman/enum-attributes.c    | 36 ++++++++++++++++---
 .../x86/dell/dell-wmi-sysman/int-attributes.c | 16 +++++++++
 .../dell/dell-wmi-sysman/passobj-attributes.c |  6 ++++
 .../dell/dell-wmi-sysman/string-attributes.c  | 16 ++++++++-
 .../x86/dell/dell-wmi-sysman/sysman.c         | 17 ++++++---
 6 files changed, 84 insertions(+), 12 deletions(-)
drivers/platform/x86/dell/dell-wmi-sysman/dell-wmi-sysman.h +4 -1
index b80f2a62ea3f..3ad33a094588 100644
@@ -152,12 +152,15 @@ static ssize_t curr_val##_store(struct kobject *kobj,				\
 	return ret ? ret : count;						\
 }
 
+#define check_property_type(attr, prop, valuetype)				\
+	(attr##_obj[prop].type != valuetype)
+
 union acpi_object *get_wmiobj_pointer(int instance_id, const char *guid_string);
 int get_instance_count(const char *guid_string);
 void strlcpy_attr(char *dest, char *src);
 
 int populate_enum_data(union acpi_object *enumeration_obj, int instance_id,
-			struct kobject *attr_name_kobj);
+			struct kobject *attr_name_kobj, u32 enum_property_count);
 int alloc_enum_data(void);
 void exit_enum_attributes(void);
 
drivers/platform/x86/dell/dell-wmi-sysman/enum-attributes.c +19 -2
index 091e48c217ed..70f4ace56ec3 100644
@@ -132,39 +132,65 @@ int alloc_enum_data(void)
  * @enumeration_obj: ACPI object with enumeration data
  * @instance_id: The instance to enumerate
  * @attr_name_kobj: The parent kernel object
+ * @enum_property_count: Total properties count under enumeration type
  */
 int populate_enum_data(union acpi_object *enumeration_obj, int instance_id,
-			struct kobject *attr_name_kobj)
+			struct kobject *attr_name_kobj, u32 enum_property_count)
 {
 	int i, next_obj, value_modifier_count, possible_values_count;
 
 	wmi_priv.enumeration_data[instance_id].attr_name_kobj = attr_name_kobj;
+	if (check_property_type(enumeration, ATTR_NAME, ACPI_TYPE_STRING))
+		return -EINVAL;
 	strlcpy_attr(wmi_priv.enumeration_data[instance_id].attribute_name,
 		enumeration_obj[ATTR_NAME].string.pointer);
+	if (check_property_type(enumeration, DISPL_NAME_LANG_CODE, ACPI_TYPE_STRING))
+		return -EINVAL;
 	strlcpy_attr(wmi_priv.enumeration_data[instance_id].display_name_language_code,
 		enumeration_obj[DISPL_NAME_LANG_CODE].string.pointer);
+	if (check_property_type(enumeration, DISPLAY_NAME, ACPI_TYPE_STRING))
+		return -EINVAL;
 	strlcpy_attr(wmi_priv.enumeration_data[instance_id].display_name,
 		enumeration_obj[DISPLAY_NAME].string.pointer);
+	if (check_property_type(enumeration, DEFAULT_VAL, ACPI_TYPE_STRING))
+		return -EINVAL;
 	strlcpy_attr(wmi_priv.enumeration_data[instance_id].default_value,
 		enumeration_obj[DEFAULT_VAL].string.pointer);
+	if (check_property_type(enumeration, MODIFIER, ACPI_TYPE_STRING))
+		return -EINVAL;
 	strlcpy_attr(wmi_priv.enumeration_data[instance_id].dell_modifier,
 		enumeration_obj[MODIFIER].string.pointer);
 
 	next_obj = MODIFIER + 1;
 
-	value_modifier_count = (uintptr_t)enumeration_obj[next_obj].string.pointer;
+	if (next_obj >= enum_property_count)
+		return -EINVAL;
+
+	if (check_property_type(enumeration, next_obj, ACPI_TYPE_INTEGER))
+		return -EINVAL;
+	value_modifier_count = (uintptr_t)enumeration_obj[next_obj++].string.pointer;
 
 	for (i = 0; i < value_modifier_count; i++) {
+		if (next_obj >= enum_property_count)

drivers/platform/x86/dell/dell-wmi-sysman/enum-attributes.c int alloc_enum_data(void) · line 163

Quoted 10 lines
drivers/platform/x86/dell/dell-wmi-sysman/enum-attributes.c +4 -2
+			return -EINVAL;
+		if (check_property_type(enumeration, next_obj, ACPI_TYPE_STRING))
+			return -EINVAL;
 		strcat(wmi_priv.enumeration_data[instance_id].dell_value_modifier,
-			enumeration_obj[++next_obj].string.pointer);
+			enumeration_obj[next_obj++].string.pointer);
 		strcat(wmi_priv.enumeration_data[instance_id].dell_value_modifier, ";");
 	}
 
-	possible_values_count = (uintptr_t) enumeration_obj[++next_obj].string.pointer;

You are missing a:

	if (next_obj >= enum_property_count)
		return -EINVAL;

Check here.

Quoted 136 lines
drivers/platform/x86/dell/dell-wmi-sysman/enum-attributes.c +8 -1
+	if (check_property_type(enumeration, next_obj, ACPI_TYPE_INTEGER))
+		return -EINVAL;
+	possible_values_count = (uintptr_t) enumeration_obj[next_obj++].string.pointer;
 
 	for (i = 0; i < possible_values_count; i++) {
+		if (next_obj >= enum_property_count)
+			return -EINVAL;
+		if (check_property_type(enumeration, next_obj, ACPI_TYPE_STRING))
+			return -EINVAL;
 		strcat(wmi_priv.enumeration_data[instance_id].possible_values,
-			enumeration_obj[++next_obj].string.pointer);
+			enumeration_obj[next_obj++].string.pointer);
 		strcat(wmi_priv.enumeration_data[instance_id].possible_values, ";");
 	}
 
drivers/platform/x86/dell/dell-wmi-sysman/int-attributes.c +16 -0
index 8a49ba6e44f9..951e75b538fa 100644
@@ -141,20 +141,36 @@ int populate_int_data(union acpi_object *integer_obj, int instance_id,
 			struct kobject *attr_name_kobj)
 {
 	wmi_priv.integer_data[instance_id].attr_name_kobj = attr_name_kobj;
+	if (check_property_type(integer, ATTR_NAME, ACPI_TYPE_STRING))
+		return -EINVAL;
 	strlcpy_attr(wmi_priv.integer_data[instance_id].attribute_name,
 		integer_obj[ATTR_NAME].string.pointer);
+	if (check_property_type(integer, DISPL_NAME_LANG_CODE, ACPI_TYPE_STRING))
+		return -EINVAL;
 	strlcpy_attr(wmi_priv.integer_data[instance_id].display_name_language_code,
 		integer_obj[DISPL_NAME_LANG_CODE].string.pointer);
+	if (check_property_type(integer, DISPLAY_NAME, ACPI_TYPE_STRING))
+		return -EINVAL;
 	strlcpy_attr(wmi_priv.integer_data[instance_id].display_name,
 		integer_obj[DISPLAY_NAME].string.pointer);
+	if (check_property_type(integer, DEFAULT_VAL, ACPI_TYPE_INTEGER))
+		return -EINVAL;
 	wmi_priv.integer_data[instance_id].default_value =
 		(uintptr_t)integer_obj[DEFAULT_VAL].string.pointer;
+	if (check_property_type(integer, MODIFIER, ACPI_TYPE_STRING))
+		return -EINVAL;
 	strlcpy_attr(wmi_priv.integer_data[instance_id].dell_modifier,
 		integer_obj[MODIFIER].string.pointer);
+	if (check_property_type(integer, MIN_VALUE, ACPI_TYPE_INTEGER))
+		return -EINVAL;
 	wmi_priv.integer_data[instance_id].min_value =
 		(uintptr_t)integer_obj[MIN_VALUE].string.pointer;
+	if (check_property_type(integer, MAX_VALUE, ACPI_TYPE_INTEGER))
+		return -EINVAL;
 	wmi_priv.integer_data[instance_id].max_value =
 		(uintptr_t)integer_obj[MAX_VALUE].string.pointer;
+	if (check_property_type(integer, SCALAR_INCR, ACPI_TYPE_INTEGER))
+		return -EINVAL;
 	wmi_priv.integer_data[instance_id].scalar_increment =
 		(uintptr_t)integer_obj[SCALAR_INCR].string.pointer;
 
drivers/platform/x86/dell/dell-wmi-sysman/passobj-attributes.c +6 -0
index 834b3e82ad9f..230e6ee96636 100644
@@ -159,10 +159,16 @@ int alloc_po_data(void)
 int populate_po_data(union acpi_object *po_obj, int instance_id, struct kobject *attr_name_kobj)
 {
 	wmi_priv.po_data[instance_id].attr_name_kobj = attr_name_kobj;
+	if (check_property_type(po, ATTR_NAME, ACPI_TYPE_STRING))
+		return -EINVAL;
 	strlcpy_attr(wmi_priv.po_data[instance_id].attribute_name,
 		     po_obj[ATTR_NAME].string.pointer);
+	if (check_property_type(po, MIN_PASS_LEN, ACPI_TYPE_INTEGER))
+		return -EINVAL;
 	wmi_priv.po_data[instance_id].min_password_length =
 		(uintptr_t)po_obj[MIN_PASS_LEN].string.pointer;
+	if (check_property_type(po, MAX_PASS_LEN, ACPI_TYPE_INTEGER))
+		return -EINVAL;
 	wmi_priv.po_data[instance_id].max_password_length =
 		(uintptr_t) po_obj[MAX_PASS_LEN].string.pointer;
 
drivers/platform/x86/dell/dell-wmi-sysman/string-attributes.c +15 -1
index 552537852459..c392f0ecf8b5 100644
@@ -118,24 +118,38 @@ int alloc_str_data(void)
 
 /**
  * populate_str_data() - Populate all properties of an instance under string attribute
- * @str_obj: ACPI object with integer data
+ * @str_obj: ACPI object with string data
  * @instance_id: The instance to enumerate
  * @attr_name_kobj: The parent kernel object
  */
 int populate_str_data(union acpi_object *str_obj, int instance_id, struct kobject *attr_name_kobj)
 {
 	wmi_priv.str_data[instance_id].attr_name_kobj = attr_name_kobj;
+	if (check_property_type(str, ATTR_NAME, ACPI_TYPE_STRING))
+		return -EINVAL;
 	strlcpy_attr(wmi_priv.str_data[instance_id].attribute_name,
 		     str_obj[ATTR_NAME].string.pointer);
+	if (check_property_type(str, DISPL_NAME_LANG_CODE, ACPI_TYPE_STRING))
+		return -EINVAL;
 	strlcpy_attr(wmi_priv.str_data[instance_id].display_name_language_code,
 		     str_obj[DISPL_NAME_LANG_CODE].string.pointer);
+	if (check_property_type(str, DISPLAY_NAME, ACPI_TYPE_STRING))
+		return -EINVAL;
 	strlcpy_attr(wmi_priv.str_data[instance_id].display_name,
 		     str_obj[DISPLAY_NAME].string.pointer);
+	if (check_property_type(str, DEFAULT_VAL, ACPI_TYPE_STRING))
+		return -EINVAL;
 	strlcpy_attr(wmi_priv.str_data[instance_id].default_value,
 		     str_obj[DEFAULT_VAL].string.pointer);
+	if (check_property_type(str, MODIFIER, ACPI_TYPE_STRING))
+		return -EINVAL;
 	strlcpy_attr(wmi_priv.str_data[instance_id].dell_modifier,
 		     str_obj[MODIFIER].string.pointer);
+	if (check_property_type(str, MIN_LEN, ACPI_TYPE_INTEGER))
+		return -EINVAL;
 	wmi_priv.str_data[instance_id].min_length = (uintptr_t)str_obj[MIN_LEN].string.pointer;
+	if (check_property_type(str, MAX_LEN, ACPI_TYPE_INTEGER))
+		return -EINVAL;
 	wmi_priv.str_data[instance_id].max_length = (uintptr_t) str_obj[MAX_LEN].string.pointer;
 
 	return sysfs_create_group(attr_name_kobj, &str_attr_group);
drivers/platform/x86/dell/dell-wmi-sysman/sysman.c +3 -4
index c8d276d78e92..5276e8c5aad5 100644
@@ -412,10 +412,16 @@ static int init_bios_attributes(int attr_type, const char *guid)
 		return retval;
 
 	switch (attr_type) {
-	case ENUM:	min_elements = 8;	break;
-	case INT:	min_elements = 9;	break;
-	case STR:	min_elements = 8;	break;
-	case PO:	min_elements = 4;	break;
+	case ENUM:
+	case STR:
+		min_elements = 8;

drivers/platform/x86/dell/dell-wmi-sysman/sysman.c static int init_bios_attributes(int attr_type, const char *guid) · line 427

Quoted 10 lines
drivers/platform/x86/dell/dell-wmi-sysman/sysman.c +7 -0
+		break;
+	case INT:
+		min_elements = 9;
+		break;
+	case PO:
+		min_elements = 4;
+		break;
 	default:
 		pr_err("Error: Unknown attr_type: %d\n", attr_type);
 		return -EINVAL;

Please drop these unrelated changes. If you want to change this please submit a separate patch for it, but I would prefer to keep this as is.

drivers/platform/x86/dell/dell-wmi-sysman/sysman.c static int init_bios_attributes(int attr_type, const char *guid) · line 494

Quoted 11 lines
drivers/platform/x86/dell/dell-wmi-sysman/sysman.c +2 -1
@@ -481,7 +487,8 @@ static int init_bios_attributes(int attr_type, const char *guid)
 		/* enumerate all of this attribute */
 		switch (attr_type) {
 		case ENUM:
-			retval = populate_enum_data(elements, instance_id, attr_name_kobj);
+			retval = populate_enum_data(elements, instance_id, attr_name_kobj,
+					obj->package.count);
 			break;
 		case INT:
 			retval = populate_int_data(elements, instance_id, attr_name_kobj);

Regards,

Hans

maintainer
#2 lore raw

Hi,

Quoted 153 lines

-----Original Message-----
From: Hans de Goede <[email protected]>
Sent: Monday, May 10, 2021 3:06 PM
To: Prasanth KSR; [email protected]
Cc: LKML; [email protected]; Ksr, Prasanth; Bharathi, Divya
Subject: Re: [PATCH] platform/x86: dell-wmi-sysman: Make populate_foo_data functions more robust

[EXTERNAL EMAIL]

Hi,

Quoted 7 lines · Prasanth KSR

1. Check acpi type before assignment of each property value

2. Add boundary check for properties count

Thanks this mostly looks good, 2 small remarks inline below.

Once those are fixed this is ready for merging.

drivers/platform/x86/dell/dell-wmi-sysman/dell-wmi-sysman.h static ssize_t curr_val##_store(struct kobject

Quoted 16 lines
---
 .../dell/dell-wmi-sysman/dell-wmi-sysman.h    |  5 ++-
 .../dell/dell-wmi-sysman/enum-attributes.c    | 36 ++++++++++++++++---
 .../x86/dell/dell-wmi-sysman/int-attributes.c | 16 +++++++++
.../dell/dell-wmi-sysman/passobj-attributes.c |  6 ++++
.../dell/dell-wmi-sysman/string-attributes.c  | 16 ++++++++-
 .../x86/dell/dell-wmi-sysman/sysman.c         | 17 ++++++---
 6 files changed, 84 insertions(+), 12 deletions(-)

diff --git a/drivers/platform/x86/dell/dell-wmi-sysman/dell-wmi-sysman.h b/drivers/platform/x86/dell/dell-wmi-sysman/dell-wmi-sysman.h index b80f2a62ea3f..3ad33a094588 100644

drivers/platform/x86/dell/dell-wmi-sysman/dell-wmi-sysman.h +0 -0
@@ -152,12 +152,15 @@ static ssize_t curr_val##_store(struct kobject

*kobj, \

drivers/platform/x86/dell/dell-wmi-sysman/dell-wmi-sysman.h static ssize_t curr_val##_store(struct kobject *kobj, \

Quoted 4 lines
drivers/platform/x86/dell/dell-wmi-sysman/dell-wmi-sysman.h +1 -0
 	return ret ? ret : count;						\
 }
 
+#define check_property_type(attr, prop, valuetype)
		\

drivers/platform/x86/dell/dell-wmi-sysman/dell-wmi-sysman.h static ssize_t curr_val##_store(struct kobject · line 162

Quoted 7 lines
drivers/platform/x86/dell/dell-wmi-sysman/dell-wmi-sysman.h +2 -0
+	(attr##_obj[prop].type != valuetype)
+
 union acpi_object *get_wmiobj_pointer(int instance_id, const char
 *guid_string);  int get_instance_count(const char *guid_string);  void
 strlcpy_attr(char *dest, char *src);
 
 int populate_enum_data(union acpi_object *enumeration_obj, int

instance_id,

drivers/platform/x86/dell/dell-wmi-sysman/dell-wmi-sysman.h static ssize_t curr_val##_store(struct kobject · line 163

Quoted 2 lines
drivers/platform/x86/dell/dell-wmi-sysman/dell-wmi-sysman.h +1 -1
-			struct kobject *attr_name_kobj);
+			struct kobject *attr_name_kobj, u32

enum_property_count);

Quoted 10 lines
drivers/platform/x86/dell/dell-wmi-sysman/dell-wmi-sysman.h +0 -0
 int alloc_enum_data(void);
 void exit_enum_attributes(void);
 

diff --git a/drivers/platform/x86/dell/dell-wmi-sysman/enum-attributes.c b/drivers/platform/x86/dell/dell-wmi-sysman/enum-attributes.c index 091e48c217ed..70f4ace56ec3 100644

drivers/platform/x86/dell/dell-wmi-sysman/enum-attributes.c int alloc_enum_data(void) · line 138

Quoted 7 lines
drivers/platform/x86/dell/dell-wmi-sysman/enum-attributes.c +2 -0
@@ -132,39 +132,65 @@ int alloc_enum_data(void)
  * @enumeration_obj: ACPI object with enumeration data
  * @instance_id: The instance to enumerate
  * @attr_name_kobj: The parent kernel object
+ * @enum_property_count: Total properties count under enumeration
+ type
  */
 int populate_enum_data(union acpi_object *enumeration_obj, int

instance_id,

drivers/platform/x86/dell/dell-wmi-sysman/enum-attributes.c int alloc_enum_data(void) · line 139

Quoted 2 lines
drivers/platform/x86/dell/dell-wmi-sysman/enum-attributes.c +1 -1
-			struct kobject *attr_name_kobj)
+			struct kobject *attr_name_kobj, u32

enum_property_count)

drivers/platform/x86/dell/dell-wmi-sysman/enum-attributes.c int alloc_enum_data(void)

Quoted 6 lines
drivers/platform/x86/dell/dell-wmi-sysman/enum-attributes.c +1 -0
 {
 	int i, next_obj, value_modifier_count, possible_values_count;
 
 	wmi_priv.enumeration_data[instance_id].attr_name_kobj =
 attr_name_kobj;
+	if (check_property_type(enumeration, ATTR_NAME,

ACPI_TYPE_STRING))

drivers/platform/x86/dell/dell-wmi-sysman/enum-attributes.c int alloc_enum_data(void) · line 147

Quoted 2 lines
drivers/platform/x86/dell/dell-wmi-sysman/enum-attributes.c +1 -0
+		return -EINVAL;
 

strlcpy_attr(wmi_priv.enumeration_data[instance_id].attribute_na
me,

drivers/platform/x86/dell/dell-wmi-sysman/enum-attributes.c int alloc_enum_data(void) · line 149

Quoted 2 lines
drivers/platform/x86/dell/dell-wmi-sysman/enum-attributes.c +1 -0
 		enumeration_obj[ATTR_NAME].string.pointer);
+	if (check_property_type(enumeration, DISPL_NAME_LANG_CODE,

ACPI_TYPE_STRING))

drivers/platform/x86/dell/dell-wmi-sysman/enum-attributes.c int alloc_enum_data(void) · line 151

Quoted 2 lines
drivers/platform/x86/dell/dell-wmi-sysman/enum-attributes.c +1 -0
+		return -EINVAL;
 

strlcpy_attr(wmi_priv.enumeration_data[instance_id].display_name
_language_code,

Quoted 1 line
	enumeration_obj[DISPL_NAME_LANG_CODE].string.pointer);

drivers/platform/x86/dell/dell-wmi-sysman/enum-attributes.c

Quoted 1 line
drivers/platform/x86/dell/dell-wmi-sysman/enum-attributes.c +1 -0
+	if (check_property_type(enumeration, DISPLAY_NAME,

ACPI_TYPE_STRING))

drivers/platform/x86/dell/dell-wmi-sysman/enum-attributes.c

Quoted 2 lines
drivers/platform/x86/dell/dell-wmi-sysman/enum-attributes.c +1 -0
+		return -EINVAL;

strlcpy_attr(wmi_priv.enumeration_data[instance_id].display_name
,

drivers/platform/x86/dell/dell-wmi-sysman/enum-attributes.c

Quoted 2 lines
drivers/platform/x86/dell/dell-wmi-sysman/enum-attributes.c +1 -0
 		enumeration_obj[DISPLAY_NAME].string.pointer);
+	if (check_property_type(enumeration, DEFAULT_VAL,

ACPI_TYPE_STRING))

drivers/platform/x86/dell/dell-wmi-sysman/enum-attributes.c

Quoted 2 lines
drivers/platform/x86/dell/dell-wmi-sysman/enum-attributes.c +1 -0
+		return -EINVAL;

strlcpy_attr(wmi_priv.enumeration_data[instance_id].default_value
,

drivers/platform/x86/dell/dell-wmi-sysman/enum-attributes.c

Quoted 2 lines
drivers/platform/x86/dell/dell-wmi-sysman/enum-attributes.c +1 -0
 		enumeration_obj[DEFAULT_VAL].string.pointer);
+	if (check_property_type(enumeration, MODIFIER,

ACPI_TYPE_STRING))

drivers/platform/x86/dell/dell-wmi-sysman/enum-attributes.c int alloc_enum_data(void)

Quoted 7 lines
drivers/platform/x86/dell/dell-wmi-sysman/enum-attributes.c +1 -1
+		return -EINVAL;
 	strlcpy_attr(wmi_priv.enumeration_data[instance_id].dell_modifier,
 		enumeration_obj[MODIFIER].string.pointer);
 
 	next_obj = MODIFIER + 1;
 
-	value_modifier_count =

(uintptr_t)enumeration_obj[next_obj].string.pointer;

drivers/platform/x86/dell/dell-wmi-sysman/enum-attributes.c int alloc_enum_data(void)

Quoted 4 lines
drivers/platform/x86/dell/dell-wmi-sysman/enum-attributes.c +4 -0
+	if (next_obj >= enum_property_count)
+		return -EINVAL;
+
+	if (check_property_type(enumeration, next_obj,

ACPI_TYPE_INTEGER))

drivers/platform/x86/dell/dell-wmi-sysman/enum-attributes.c int alloc_enum_data(void)

Quoted 8 lines
drivers/platform/x86/dell/dell-wmi-sysman/enum-attributes.c +6 -0
+		return -EINVAL;
+	value_modifier_count =
+(uintptr_t)enumeration_obj[next_obj++].string.pointer;
 
 	for (i = 0; i < value_modifier_count; i++) {
+		if (next_obj >= enum_property_count)
+			return -EINVAL;
+		if (check_property_type(enumeration, next_obj,

ACPI_TYPE_STRING))

drivers/platform/x86/dell/dell-wmi-sysman/enum-attributes.c

Quoted 2 lines
drivers/platform/x86/dell/dell-wmi-sysman/enum-attributes.c +1 -0
+			return -EINVAL;

strcat(wmi_priv.enumeration_data[instance_id].dell_value_modifier
,

drivers/platform/x86/dell/dell-wmi-sysman/enum-attributes.c

Quoted 3 lines
drivers/platform/x86/dell/dell-wmi-sysman/enum-attributes.c +1 -1
-			enumeration_obj[++next_obj].string.pointer);
+			enumeration_obj[next_obj++].string.pointer);

strcat(wmi_priv.enumeration_data[instance_id].dell_value_modifier
, ";");

drivers/platform/x86/dell/dell-wmi-sysman/enum-attributes.c

Quoted 3 lines
drivers/platform/x86/dell/dell-wmi-sysman/enum-attributes.c +0 -1
 	}
 
-	possible_values_count = (uintptr_t)

enumeration_obj[++next_obj].string.pointer;

Quoted 6 lines

You are missing a:

	if (next_obj >= enum_property_count)
		return -EINVAL;

Check here.

Ack will address this.

Quoted 173 lines

drivers/platform/x86/dell/dell-wmi-sysman/enum-attributes.c

Quoted 3 lines
drivers/platform/x86/dell/dell-wmi-sysman/enum-attributes.c +1 -0
+	if (check_property_type(enumeration, next_obj,

ACPI_TYPE_INTEGER))

drivers/platform/x86/dell/dell-wmi-sysman/enum-attributes.c int alloc_enum_data(void)

Quoted 8 lines
drivers/platform/x86/dell/dell-wmi-sysman/enum-attributes.c +6 -0
+		return -EINVAL;
+	possible_values_count = (uintptr_t)
+enumeration_obj[next_obj++].string.pointer;
 
 	for (i = 0; i < possible_values_count; i++) {
+		if (next_obj >= enum_property_count)
+			return -EINVAL;
+		if (check_property_type(enumeration, next_obj,

ACPI_TYPE_STRING))

drivers/platform/x86/dell/dell-wmi-sysman/enum-attributes.c

Quoted 2 lines
drivers/platform/x86/dell/dell-wmi-sysman/enum-attributes.c +1 -0
+			return -EINVAL;

strcat(wmi_priv.enumeration_data[instance_id].possible_values,

drivers/platform/x86/dell/dell-wmi-sysman/enum-attributes.c

Quoted 3 lines
drivers/platform/x86/dell/dell-wmi-sysman/enum-attributes.c +1 -1
-			enumeration_obj[++next_obj].string.pointer);
+			enumeration_obj[next_obj++].string.pointer);

strcat(wmi_priv.enumeration_data[instance_id].possible_values,
";");

drivers/platform/x86/dell/dell-wmi-sysman/int-attributes.c int populate_int_data(union acpi_object

Quoted 9 lines

}

diff --git a/drivers/platform/x86/dell/dell-wmi-sysman/int-attributes.c b/drivers/platform/x86/dell/dell-wmi-sysman/int-attributes.c index 8a49ba6e44f9..951e75b538fa 100644

drivers/platform/x86/dell/dell-wmi-sysman/int-attributes.c +0 -0
@@ -141,20 +141,36 @@ int populate_int_data(union acpi_object

*integer_obj, int instance_id,

drivers/platform/x86/dell/dell-wmi-sysman/int-attributes.c int populate_int_data(union acpi_object *integer_obj, int instance_id,

Quoted 3 lines
drivers/platform/x86/dell/dell-wmi-sysman/int-attributes.c +0 -0
 			struct kobject *attr_name_kobj)
 {
 	wmi_priv.integer_data[instance_id].attr_name_kobj =

attr_name_kobj;

drivers/platform/x86/dell/dell-wmi-sysman/int-attributes.c int populate_int_data(union acpi_object *integer_obj, int instance_id,

Quoted 5 lines
drivers/platform/x86/dell/dell-wmi-sysman/int-attributes.c +3 -0
+	if (check_property_type(integer, ATTR_NAME, ACPI_TYPE_STRING))
+		return -EINVAL;
 	strlcpy_attr(wmi_priv.integer_data[instance_id].attribute_name,
 		integer_obj[ATTR_NAME].string.pointer);
+	if (check_property_type(integer, DISPL_NAME_LANG_CODE,

ACPI_TYPE_STRING))

drivers/platform/x86/dell/dell-wmi-sysman/int-attributes.c int populate_int_data(union acpi_object · line 150

Quoted 2 lines
drivers/platform/x86/dell/dell-wmi-sysman/int-attributes.c +1 -0
+		return -EINVAL;
 

strlcpy_attr(wmi_priv.integer_data[instance_id].display_name_lang
uage_code,

drivers/platform/x86/dell/dell-wmi-sysman/int-attributes.c int populate_int_data(union acpi_object · line 152

Quoted 2 lines
drivers/platform/x86/dell/dell-wmi-sysman/int-attributes.c +1 -0
 		integer_obj[DISPL_NAME_LANG_CODE].string.pointer);
+	if (check_property_type(integer, DISPLAY_NAME,

ACPI_TYPE_STRING))

drivers/platform/x86/dell/dell-wmi-sysman/int-attributes.c int populate_int_data(union acpi_object *integer_obj, int instance_id,

Quoted 4 lines
drivers/platform/x86/dell/dell-wmi-sysman/int-attributes.c +2 -0
+		return -EINVAL;
 	strlcpy_attr(wmi_priv.integer_data[instance_id].display_name,
 		integer_obj[DISPLAY_NAME].string.pointer);
+	if (check_property_type(integer, DEFAULT_VAL,

ACPI_TYPE_INTEGER))

drivers/platform/x86/dell/dell-wmi-sysman/int-attributes.c int populate_int_data(union acpi_object *integer_obj, int instance_id,

Quoted 8 lines
drivers/platform/x86/dell/dell-wmi-sysman/int-attributes.c +4 -0
+		return -EINVAL;
 	wmi_priv.integer_data[instance_id].default_value =
 		(uintptr_t)integer_obj[DEFAULT_VAL].string.pointer;
+	if (check_property_type(integer, MODIFIER, ACPI_TYPE_STRING))
+		return -EINVAL;
 	strlcpy_attr(wmi_priv.integer_data[instance_id].dell_modifier,
 		integer_obj[MODIFIER].string.pointer);
+	if (check_property_type(integer, MIN_VALUE,

ACPI_TYPE_INTEGER))

drivers/platform/x86/dell/dell-wmi-sysman/int-attributes.c int populate_int_data(union acpi_object *integer_obj, int instance_id,

Quoted 4 lines
drivers/platform/x86/dell/dell-wmi-sysman/int-attributes.c +2 -0
+		return -EINVAL;
 	wmi_priv.integer_data[instance_id].min_value =
 		(uintptr_t)integer_obj[MIN_VALUE].string.pointer;
+	if (check_property_type(integer, MAX_VALUE,

ACPI_TYPE_INTEGER))

drivers/platform/x86/dell/dell-wmi-sysman/int-attributes.c int populate_int_data(union acpi_object *integer_obj, int instance_id,

Quoted 4 lines
drivers/platform/x86/dell/dell-wmi-sysman/int-attributes.c +2 -0
+		return -EINVAL;
 	wmi_priv.integer_data[instance_id].max_value =
 		(uintptr_t)integer_obj[MAX_VALUE].string.pointer;
+	if (check_property_type(integer, SCALAR_INCR,

ACPI_TYPE_INTEGER))

Quoted 45 lines
drivers/platform/x86/dell/dell-wmi-sysman/int-attributes.c +1 -0
+		return -EINVAL;
 	wmi_priv.integer_data[instance_id].scalar_increment =
 		(uintptr_t)integer_obj[SCALAR_INCR].string.pointer;
 

diff --git a/drivers/platform/x86/dell/dell-wmi-sysman/passobj-attributes.c b/drivers/platform/x86/dell/dell-wmi-sysman/passobj-attributes.c index 834b3e82ad9f..230e6ee96636 100644

drivers/platform/x86/dell/dell-wmi-sysman/passobj-attributes.c +0 -0
@@ -159,10 +159,16 @@ int alloc_po_data(void)  int

populate_po_data(union acpi_object *po_obj, int instance_id, struct kobject *attr_name_kobj) {

drivers/platform/x86/dell/dell-wmi-sysman/passobj-attributes.c +6 -0
 	wmi_priv.po_data[instance_id].attr_name_kobj = attr_name_kobj;
+	if (check_property_type(po, ATTR_NAME, ACPI_TYPE_STRING))
+		return -EINVAL;
 	strlcpy_attr(wmi_priv.po_data[instance_id].attribute_name,
 		     po_obj[ATTR_NAME].string.pointer);
+	if (check_property_type(po, MIN_PASS_LEN, ACPI_TYPE_INTEGER))
+		return -EINVAL;
 	wmi_priv.po_data[instance_id].min_password_length =
 		(uintptr_t)po_obj[MIN_PASS_LEN].string.pointer;
+	if (check_property_type(po, MAX_PASS_LEN, ACPI_TYPE_INTEGER))
+		return -EINVAL;
 	wmi_priv.po_data[instance_id].max_password_length =
 		(uintptr_t) po_obj[MAX_PASS_LEN].string.pointer;

diff --git a/drivers/platform/x86/dell/dell-wmi-sysman/string-attributes.c b/drivers/platform/x86/dell/dell-wmi-sysman/string-attributes.c index 552537852459..c392f0ecf8b5 100644

drivers/platform/x86/dell/dell-wmi-sysman/string-attributes.c +0 -0
@@ -118,24 +118,38 @@ int alloc_str_data(void)
 
 /**
  * populate_str_data() - Populate all properties of an instance under

string attribute
- * @str_obj: ACPI object with integer data
+ * @str_obj: ACPI object with string data
* @instance_id: The instance to enumerate
* @attr_name_kobj: The parent kernel object
*/
int populate_str_data(union acpi_object *str_obj, int instance_id,
struct kobject *attr_name_kobj) {

drivers/platform/x86/dell/dell-wmi-sysman/string-attributes.c int alloc_str_data(void)

Quoted 6 lines
drivers/platform/x86/dell/dell-wmi-sysman/string-attributes.c +3 -0
 	wmi_priv.str_data[instance_id].attr_name_kobj = attr_name_kobj;
+	if (check_property_type(str, ATTR_NAME, ACPI_TYPE_STRING))
+		return -EINVAL;
 	strlcpy_attr(wmi_priv.str_data[instance_id].attribute_name,
 		     str_obj[ATTR_NAME].string.pointer);
+	if (check_property_type(str, DISPL_NAME_LANG_CODE,

ACPI_TYPE_STRING))

drivers/platform/x86/dell/dell-wmi-sysman/string-attributes.c

Quoted 2 lines
drivers/platform/x86/dell/dell-wmi-sysman/string-attributes.c +1 -0
+		return -EINVAL;

strlcpy_attr(wmi_priv.str_data[instance_id].display_name_language
_code,

drivers/platform/x86/dell/dell-wmi-sysman/sysman.c static int init_bios_attributes(int attr_type, const

Quoted 29 lines
drivers/platform/x86/dell/dell-wmi-sysman/string-attributes.c +8 -0
 		     str_obj[DISPL_NAME_LANG_CODE].string.pointer);
+	if (check_property_type(str, DISPLAY_NAME, ACPI_TYPE_STRING))
+		return -EINVAL;
 	strlcpy_attr(wmi_priv.str_data[instance_id].display_name,
 		     str_obj[DISPLAY_NAME].string.pointer);
+	if (check_property_type(str, DEFAULT_VAL, ACPI_TYPE_STRING))
+		return -EINVAL;
 	strlcpy_attr(wmi_priv.str_data[instance_id].default_value,
 		     str_obj[DEFAULT_VAL].string.pointer);
+	if (check_property_type(str, MODIFIER, ACPI_TYPE_STRING))
+		return -EINVAL;
 	strlcpy_attr(wmi_priv.str_data[instance_id].dell_modifier,
 		     str_obj[MODIFIER].string.pointer);
+	if (check_property_type(str, MIN_LEN, ACPI_TYPE_INTEGER))
+		return -EINVAL;
 	wmi_priv.str_data[instance_id].min_length =

(uintptr_t)str_obj[MIN_LEN].string.pointer;

drivers/platform/x86/dell/dell-wmi-sysman/string-attributes.c +2 -0
+	if (check_property_type(str, MAX_LEN, ACPI_TYPE_INTEGER))
+		return -EINVAL;
 	wmi_priv.str_data[instance_id].max_length = (uintptr_t)

str_obj[MAX_LEN].string.pointer;

return sysfs_create_group(attr_name_kobj, &str_attr_group); diff
--git a/drivers/platform/x86/dell/dell-wmi-sysman/sysman.c b/drivers/platform/x86/dell/dell-wmi-sysman/sysman.c
index c8d276d78e92..5276e8c5aad5 100644

drivers/platform/x86/dell/dell-wmi-sysman/sysman.c +0 -0
@@ -412,10 +412,16 @@ static int init_bios_attributes(int attr_type, const

char *guid)

Quoted 15 lines
drivers/platform/x86/dell/dell-wmi-sysman/sysman.c +8 -4
 		return retval;
 
 	switch (attr_type) {
-	case ENUM:	min_elements = 8;	break;
-	case INT:	min_elements = 9;	break;
-	case STR:	min_elements = 8;	break;
-	case PO:	min_elements = 4;	break;
+	case ENUM:
+	case STR:
+		min_elements = 8;
+		break;
+	case INT:
+		min_elements = 9;
+		break;
+	case PO:
Quoted 8 lines

drivers/platform/x86/dell/dell-wmi-sysman/sysman.c static int init_bios_attributes(int attr_type, const char *guid) · line 427

Quoted 5 lines
drivers/platform/x86/dell/dell-wmi-sysman/sysman.c +2 -0
+		min_elements = 4;
+		break;
 	default:
 		pr_err("Error: Unknown attr_type: %d\n", attr_type);
 		return -EINVAL;

Please drop these unrelated changes. If you want to change this please submit a separate patch for it, but I would prefer to keep this as is.

Sure. Will do the same.
We addressed as checkpatch was throwing error on these lines.

Quoted 20 lines

drivers/platform/x86/dell/dell-wmi-sysman/sysman.c static int init_bios_attributes(int attr_type, const

Quoted 2 lines
drivers/platform/x86/dell/dell-wmi-sysman/sysman.c +0 -0
@@ -481,7 +487,8 @@ static int init_bios_attributes(int attr_type, const

char *guid)

drivers/platform/x86/dell/dell-wmi-sysman/sysman.c static int init_bios_attributes(int attr_type, const char *guid)

Quoted 4 lines
drivers/platform/x86/dell/dell-wmi-sysman/sysman.c +0 -1
 		/* enumerate all of this attribute */
 		switch (attr_type) {
 		case ENUM:
-			retval = populate_enum_data(elements,

instance_id, attr_name_kobj);

drivers/platform/x86/dell/dell-wmi-sysman/sysman.c static int init_bios_attributes(int attr_type, const · line 490

Quoted 1 line
drivers/platform/x86/dell/dell-wmi-sysman/sysman.c +1 -0
+			retval = populate_enum_data(elements,

instance_id, attr_name_kobj,

drivers/platform/x86/dell/dell-wmi-sysman/sysman.c static int init_bios_attributes(int attr_type, const char *guid)

Quoted 4 lines
drivers/platform/x86/dell/dell-wmi-sysman/sysman.c +1 -0
+					obj->package.count);
 			break;
 		case INT:
 			retval = populate_int_data(elements, instance_id,

attr_name_kobj);

Quoted 1 line

Regards,

Hans