Commit c9ba59258094 ("hwmon: (hp-wmi-sensors) Fix failure to load on EliteDesk 800 G6") added support for BIOS-reported WMI strings that are encoded as a length-prefixed UTF-16 ACPI_TYPE_BUFFER instead of a plain ACPI_TYPE_STRING. check_wobj(), extract_acpi_value(), and update_numeric_sensor_from_wobj() were all updated to recognize and decode this encoding. check_numeric_sensor_wobj() was missed. It performs its own independent, stricter type check on every property of a HPBIOS_BIOSNumericSensor instance: type = elements[i].type; valid_type = hp_wmi_property_map[prop]; if (type != valid_type) return -EINVAL; and, separately, on each entry of PossibleStates[]: type = elements[++i].type; if (type != valid_type) return -EINVAL; Neither site has the ACPI_TYPE_BUFFER exception that check_wobj() gained. Both populate_numeric_sensor_from_wobj() and update_numeric_sensor_from_wobj() call check_numeric_sensor_wobj() first and bail out on its -EINVAL before ever reaching the buffer-aware code in extract_acpi_value() or the CurrentState handling added to update_numeric_sensor_from_wobj(). So on any BIOS that reports Name, Description, OtherSensorType, PossibleStates, or CurrentState of a numeric sensor as a raw WMI string buffer, probing that sensor fails outright, and the buffer-decoding path added for it is unreachable dead code. Give check_numeric_sensor_wobj() the same is_raw_wmi_string() exception as check_wobj(), in both the main property loop and the PossibleStates[] sub-loop. Fixes: c9ba59258094 ("hwmon: (hp-wmi-sensors) Fix failure to load on EliteDesk 800 G6") Cc: stable@vger.kernel.org Signed-off-by: Muhammad Bilal --- drivers/hwmon/hp-wmi-sensors.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/drivers/hwmon/hp-wmi-sensors.c b/drivers/hwmon/hp-wmi-sensors.c index 03c684b..a4bb4da 100644 --- a/drivers/hwmon/hp-wmi-sensors.c +++ b/drivers/hwmon/hp-wmi-sensors.c @@ -631,8 +631,14 @@ static int check_numeric_sensor_wobj(const union acpi_object *wobj, for (i = 0; i < elem_count && prop <= last_prop; i++, prop++) { type = elements[i].type; valid_type = hp_wmi_property_map[prop]; - if (type != valid_type) + if (type != valid_type) { + if (type == ACPI_TYPE_BUFFER && + valid_type == ACPI_TYPE_STRING && + is_raw_wmi_string(elements[i].buffer.pointer, + elements[i].buffer.length)) + continue; return -EINVAL; + } switch (prop) { case HP_WMI_PROPERTY_OPERATIONAL_STATUS: @@ -651,8 +657,13 @@ static int check_numeric_sensor_wobj(const union acpi_object *wobj, /* PossibleStates[0] has already been type-checked. */ for (j = 0; i + 1 < elem_count && j + 1 < count; j++) { type = elements[++i].type; - if (type != valid_type) + if (type != valid_type) { + if (type == ACPI_TYPE_BUFFER && + is_raw_wmi_string(elements[i].buffer.pointer, + elements[i].buffer.length)) + continue; return -EINVAL; + } } /* Old variant: BaseUnits follows PossibleStates[]. */ -- 2.43.0