mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] hwmon: (hp-wmi-sensors) Improve raw WMI string handling
@ 2026-09-16 22:19 James Seo
  2026-09-16 23:33 ` Guenter Roeck
  2026-09-17  0:08 ` Guenter Roeck
  0 siblings, 2 replies; 3+ messages in thread
From: James Seo @ 2026-09-16 22:19 UTC (permalink / raw)
  To: Guenter Roeck; +Cc: linux-hwmon, linux-kernel, Muhammad Bilal, James Seo

Commit c9ba59258094 ("hwmon: (hp-wmi-sensors) Fix failure to load on
EliteDesk 800 G6") left out some logic for recognizing raw WMI
strings in check_numeric_sensor_wobj(). This issue was reported by a
user along with an incomplete and unsuitable proposed solution [1].

Add the missing logic and properly remedy the issue. Also slightly
refactor how raw WMI strings are recognized elsewhere to make the
intent that they should be treated as regular ACPI strings clearer.

Reported-by: Muhammad Bilal <meatuni001@gmail.com>
Link: https://lore.kernel.org/linux-hwmon/20260916002907.161210-1-meatuni001@gmail.com/ [1]
Fixes: c9ba59258094 ("hwmon: (hp-wmi-sensors) Fix failure to load on EliteDesk 800 G6")
Signed-off-by: James Seo <james@equiv.tech>
---
 drivers/hwmon/hp-wmi-sensors.c | 30 ++++++++++++++++++++++--------
 1 file changed, 22 insertions(+), 8 deletions(-)

diff --git a/drivers/hwmon/hp-wmi-sensors.c b/drivers/hwmon/hp-wmi-sensors.c
index 03c684ba83bd..cb2eb9bd278a 100644
--- a/drivers/hwmon/hp-wmi-sensors.c
+++ b/drivers/hwmon/hp-wmi-sensors.c
@@ -526,14 +526,12 @@ static int check_wobj(const union acpi_object *wobj,
 	for (prop = 0; prop <= last_prop; prop++) {
 		type = elements[prop].type;
 		valid_type = property_map[prop];
-		if (type != valid_type) {
-			if (type == ACPI_TYPE_BUFFER &&
-			    valid_type == ACPI_TYPE_STRING &&
-			    is_raw_wmi_string(elements[prop].buffer.pointer,
-					      elements[prop].buffer.length))
-				continue;
+		if (type == ACPI_TYPE_BUFFER &&
+		    is_raw_wmi_string(elements[prop].buffer.pointer,
+				      elements[prop].buffer.length))
+			type = ACPI_TYPE_STRING;
+		if (type != valid_type)
 			return -EINVAL;
-		}
 	}
 
 	return 0;
@@ -579,6 +577,7 @@ static int check_numeric_sensor_wobj(const union acpi_object *wobj,
 	int prop = HP_WMI_PROPERTY_NAME;
 	acpi_object_type valid_type;
 	union acpi_object *elements;
+	union acpi_object *element;
 	u32 elem_count;
 	int last_prop;
 	bool is_new;
@@ -602,13 +601,20 @@ static int check_numeric_sensor_wobj(const union acpi_object *wobj,
 	    elem_count > HP_WMI_MAX_PROPERTIES)
 		return -EINVAL;
 
-	type = elements[HP_WMI_PROPERTY_SIZE].type;
+	element = &elements[HP_WMI_PROPERTY_SIZE];
+	type = element->type;
 	switch (type) {
 	case ACPI_TYPE_INTEGER:
 		is_new = true;
 		last_prop = HP_WMI_PROPERTY_RATE_UNITS;
 		break;
 
+	case ACPI_TYPE_BUFFER:
+		if (!is_raw_wmi_string(element->buffer.pointer,
+				       element->buffer.length))
+			return -EINVAL;
+		fallthrough;
+
 	case ACPI_TYPE_STRING:
 		is_new = false;
 		last_prop = HP_WMI_PROPERTY_CURRENT_READING;
@@ -631,6 +637,10 @@ 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 == ACPI_TYPE_BUFFER &&
+		    is_raw_wmi_string(elements[i].buffer.pointer,
+				      elements[i].buffer.length))
+			type = ACPI_TYPE_STRING;
 		if (type != valid_type)
 			return -EINVAL;
 
@@ -651,6 +661,10 @@ 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 == ACPI_TYPE_BUFFER &&
+				    is_raw_wmi_string(elements[i].buffer.pointer,
+						      elements[i].buffer.length))
+					type = ACPI_TYPE_STRING;
 				if (type != valid_type)
 					return -EINVAL;
 			}
-- 
2.53.0


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] hwmon: (hp-wmi-sensors) Improve raw WMI string handling
  2026-09-16 22:19 [PATCH] hwmon: (hp-wmi-sensors) Improve raw WMI string handling James Seo
@ 2026-09-16 23:33 ` Guenter Roeck
  2026-09-17  0:08 ` Guenter Roeck
  1 sibling, 0 replies; 3+ messages in thread
From: Guenter Roeck @ 2026-09-16 23:33 UTC (permalink / raw)
  To: James Seo; +Cc: linux-hwmon, linux-kernel, Muhammad Bilal

On 9/16/26 15:19, James Seo wrote:
> Commit c9ba59258094 ("hwmon: (hp-wmi-sensors) Fix failure to load on
> EliteDesk 800 G6") left out some logic for recognizing raw WMI
> strings in check_numeric_sensor_wobj(). This issue was reported by a
> user along with an incomplete and unsuitable proposed solution [1].
> 
> Add the missing logic and properly remedy the issue. Also slightly
> refactor how raw WMI strings are recognized elsewhere to make the
> intent that they should be treated as regular ACPI strings clearer.
> 
> Reported-by: Muhammad Bilal <meatuni001@gmail.com>
> Link: https://lore.kernel.org/linux-hwmon/20260916002907.161210-1-meatuni001@gmail.com/ [1]
> Fixes: c9ba59258094 ("hwmon: (hp-wmi-sensors) Fix failure to load on EliteDesk 800 G6")
> Signed-off-by: James Seo <james@equiv.tech>

Is this v2 ? Resend of v1 ? A new patch ?

Guenter

> ---
>   drivers/hwmon/hp-wmi-sensors.c | 30 ++++++++++++++++++++++--------
>   1 file changed, 22 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/hwmon/hp-wmi-sensors.c b/drivers/hwmon/hp-wmi-sensors.c
> index 03c684ba83bd..cb2eb9bd278a 100644
> --- a/drivers/hwmon/hp-wmi-sensors.c
> +++ b/drivers/hwmon/hp-wmi-sensors.c
> @@ -526,14 +526,12 @@ static int check_wobj(const union acpi_object *wobj,
>   	for (prop = 0; prop <= last_prop; prop++) {
>   		type = elements[prop].type;
>   		valid_type = property_map[prop];
> -		if (type != valid_type) {
> -			if (type == ACPI_TYPE_BUFFER &&
> -			    valid_type == ACPI_TYPE_STRING &&
> -			    is_raw_wmi_string(elements[prop].buffer.pointer,
> -					      elements[prop].buffer.length))
> -				continue;
> +		if (type == ACPI_TYPE_BUFFER &&
> +		    is_raw_wmi_string(elements[prop].buffer.pointer,
> +				      elements[prop].buffer.length))
> +			type = ACPI_TYPE_STRING;
> +		if (type != valid_type)
>   			return -EINVAL;
> -		}
>   	}
>   
>   	return 0;
> @@ -579,6 +577,7 @@ static int check_numeric_sensor_wobj(const union acpi_object *wobj,
>   	int prop = HP_WMI_PROPERTY_NAME;
>   	acpi_object_type valid_type;
>   	union acpi_object *elements;
> +	union acpi_object *element;
>   	u32 elem_count;
>   	int last_prop;
>   	bool is_new;
> @@ -602,13 +601,20 @@ static int check_numeric_sensor_wobj(const union acpi_object *wobj,
>   	    elem_count > HP_WMI_MAX_PROPERTIES)
>   		return -EINVAL;
>   
> -	type = elements[HP_WMI_PROPERTY_SIZE].type;
> +	element = &elements[HP_WMI_PROPERTY_SIZE];
> +	type = element->type;
>   	switch (type) {
>   	case ACPI_TYPE_INTEGER:
>   		is_new = true;
>   		last_prop = HP_WMI_PROPERTY_RATE_UNITS;
>   		break;
>   
> +	case ACPI_TYPE_BUFFER:
> +		if (!is_raw_wmi_string(element->buffer.pointer,
> +				       element->buffer.length))
> +			return -EINVAL;
> +		fallthrough;
> +
>   	case ACPI_TYPE_STRING:
>   		is_new = false;
>   		last_prop = HP_WMI_PROPERTY_CURRENT_READING;
> @@ -631,6 +637,10 @@ 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 == ACPI_TYPE_BUFFER &&
> +		    is_raw_wmi_string(elements[i].buffer.pointer,
> +				      elements[i].buffer.length))
> +			type = ACPI_TYPE_STRING;
>   		if (type != valid_type)
>   			return -EINVAL;
>   
> @@ -651,6 +661,10 @@ 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 == ACPI_TYPE_BUFFER &&
> +				    is_raw_wmi_string(elements[i].buffer.pointer,
> +						      elements[i].buffer.length))
> +					type = ACPI_TYPE_STRING;
>   				if (type != valid_type)
>   					return -EINVAL;
>   			}


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] hwmon: (hp-wmi-sensors) Improve raw WMI string handling
  2026-09-16 22:19 [PATCH] hwmon: (hp-wmi-sensors) Improve raw WMI string handling James Seo
  2026-09-16 23:33 ` Guenter Roeck
@ 2026-09-17  0:08 ` Guenter Roeck
  1 sibling, 0 replies; 3+ messages in thread
From: Guenter Roeck @ 2026-09-17  0:08 UTC (permalink / raw)
  To: James Seo; +Cc: linux-hwmon, linux-kernel, Muhammad Bilal

On Wed, Sep 16, 2026 at 03:19:15PM -0700, James Seo wrote:
> Commit c9ba59258094 ("hwmon: (hp-wmi-sensors) Fix failure to load on
> EliteDesk 800 G6") left out some logic for recognizing raw WMI
> strings in check_numeric_sensor_wobj(). This issue was reported by a
> user along with an incomplete and unsuitable proposed solution [1].
> 
> Add the missing logic and properly remedy the issue. Also slightly
> refactor how raw WMI strings are recognized elsewhere to make the
> intent that they should be treated as regular ACPI strings clearer.
> 
> Reported-by: Muhammad Bilal <meatuni001@gmail.com>
> Link: https://lore.kernel.org/linux-hwmon/20260916002907.161210-1-meatuni001@gmail.com/ [1]
> Fixes: c9ba59258094 ("hwmon: (hp-wmi-sensors) Fix failure to load on EliteDesk 800 G6")
> Signed-off-by: James Seo <james@equiv.tech>

Never mind my previous reply. Applied.

Thanks,
Guenter

> ---
>  drivers/hwmon/hp-wmi-sensors.c | 30 ++++++++++++++++++++++--------
>  1 file changed, 22 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/hwmon/hp-wmi-sensors.c b/drivers/hwmon/hp-wmi-sensors.c
> index 03c684ba83bd..cb2eb9bd278a 100644
> --- a/drivers/hwmon/hp-wmi-sensors.c
> +++ b/drivers/hwmon/hp-wmi-sensors.c
> @@ -526,14 +526,12 @@ static int check_wobj(const union acpi_object *wobj,
>  	for (prop = 0; prop <= last_prop; prop++) {
>  		type = elements[prop].type;
>  		valid_type = property_map[prop];
> -		if (type != valid_type) {
> -			if (type == ACPI_TYPE_BUFFER &&
> -			    valid_type == ACPI_TYPE_STRING &&
> -			    is_raw_wmi_string(elements[prop].buffer.pointer,
> -					      elements[prop].buffer.length))
> -				continue;
> +		if (type == ACPI_TYPE_BUFFER &&
> +		    is_raw_wmi_string(elements[prop].buffer.pointer,
> +				      elements[prop].buffer.length))
> +			type = ACPI_TYPE_STRING;
> +		if (type != valid_type)
>  			return -EINVAL;
> -		}
>  	}
>  
>  	return 0;
> @@ -579,6 +577,7 @@ static int check_numeric_sensor_wobj(const union acpi_object *wobj,
>  	int prop = HP_WMI_PROPERTY_NAME;
>  	acpi_object_type valid_type;
>  	union acpi_object *elements;
> +	union acpi_object *element;
>  	u32 elem_count;
>  	int last_prop;
>  	bool is_new;
> @@ -602,13 +601,20 @@ static int check_numeric_sensor_wobj(const union acpi_object *wobj,
>  	    elem_count > HP_WMI_MAX_PROPERTIES)
>  		return -EINVAL;
>  
> -	type = elements[HP_WMI_PROPERTY_SIZE].type;
> +	element = &elements[HP_WMI_PROPERTY_SIZE];
> +	type = element->type;
>  	switch (type) {
>  	case ACPI_TYPE_INTEGER:
>  		is_new = true;
>  		last_prop = HP_WMI_PROPERTY_RATE_UNITS;
>  		break;
>  
> +	case ACPI_TYPE_BUFFER:
> +		if (!is_raw_wmi_string(element->buffer.pointer,
> +				       element->buffer.length))
> +			return -EINVAL;
> +		fallthrough;
> +
>  	case ACPI_TYPE_STRING:
>  		is_new = false;
>  		last_prop = HP_WMI_PROPERTY_CURRENT_READING;
> @@ -631,6 +637,10 @@ 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 == ACPI_TYPE_BUFFER &&
> +		    is_raw_wmi_string(elements[i].buffer.pointer,
> +				      elements[i].buffer.length))
> +			type = ACPI_TYPE_STRING;
>  		if (type != valid_type)
>  			return -EINVAL;
>  
> @@ -651,6 +661,10 @@ 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 == ACPI_TYPE_BUFFER &&
> +				    is_raw_wmi_string(elements[i].buffer.pointer,
> +						      elements[i].buffer.length))
> +					type = ACPI_TYPE_STRING;
>  				if (type != valid_type)
>  					return -EINVAL;
>  			}

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-09-17  0:08 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-16 22:19 [PATCH] hwmon: (hp-wmi-sensors) Improve raw WMI string handling James Seo
2026-09-16 23:33 ` Guenter Roeck
2026-09-17  0:08 ` Guenter Roeck

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®