Skip to contentSkip to conversation

platform/x86: acer-wmi: reject missing gaming WMI results

PATCH Superseded Yousef Alhouseen 3 participants 7 messages Jun 30 – Jul 21

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 platform/x86: acer-wmi: reject missing gaming WMI results

WMI_gaming_execute_u32_u64() returns success when firmware supplies no output object, leaving the caller output untouched. Gaming getters then inspect an uninitialized result value.

Return -ENOMSG for a missing object and -EINVAL for a missing output pointer, matching the existing malformed-result handling.

---
 drivers/platform/x86/acer-wmi.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/platform/x86/acer-wmi.c +5 -1
index e0eaaefb13d0..81d354c80cd2 100644
@@ -1581,7 +1581,11 @@ static int WMI_gaming_execute_u32_u64(u32 method_id, u32 in, u64 *out)
 		return -EIO;
 
 	obj = result.pointer;
-	if (obj && out) {
+	if (!obj) {
+		ret = -ENOMSG;
+	} else if (!out) {
+		ret = -EINVAL;
+	} else {
 		switch (obj->type) {
 		case ACPI_TYPE_INTEGER:
 			*out = obj->integer.value;
Signature · 1 line
2.54.0
#1 lore raw

Am 30.06.26 um 12:50 schrieb Yousef Alhouseen:

Quoted 6 lines

WMI_gaming_execute_u32_u64() returns success when firmware supplies no output object, leaving the caller output untouched. Gaming getters then inspect an uninitialized result value.

Return -ENOMSG for a missing object and -EINVAL for a missing output pointer, matching the existing malformed-result handling.

Good catch, but i suspect that the original intention for checking "out" was to enable callers to ignore any output values by passing "out" as NULL.

Please only return an error if obj is NULL _and_ out is not NULL.

Thanks,
Armin Wolf

Quoted 22 lines
---
  drivers/platform/x86/acer-wmi.c | 6 +++++-
  1 file changed, 5 insertions(+), 1 deletion(-)
drivers/platform/x86/acer-wmi.c +5 -1
index e0eaaefb13d0..81d354c80cd2 100644
@@ -1581,7 +1581,11 @@ static int WMI_gaming_execute_u32_u64(u32 method_id, u32 in, u64 *out)
  		return -EIO;
 
  	obj = result.pointer;
-	if (obj && out) {
+	if (!obj) {
+		ret = -ENOMSG;
+	} else if (!out) {
+		ret = -EINVAL;
+	} else {
  		switch (obj->type) {
  		case ACPI_TYPE_INTEGER:
  			*out = obj->integer.value;
#2 lore raw

Thanks, Armin. That interpretation makes sense. I’ll preserve NULL as the output-ignore case and only reject a missing object when the caller supplied an output pointer in v2.

Quoted 39 lines · Armin Wolf

Am 30.06.26 um 12:50 schrieb Yousef Alhouseen:

Quoted 6 lines

WMI_gaming_execute_u32_u64() returns success when firmware supplies no output object, leaving the caller output untouched. Gaming getters then inspect an uninitialized result value.

Return -ENOMSG for a missing object and -EINVAL for a missing output pointer, matching the existing malformed-result handling.

Good catch, but i suspect that the original intention for checking "out" was to enable callers to ignore any output values by passing "out" as NULL.

Please only return an error if obj is NULL _and_ out is not NULL.

Thanks,
Armin Wolf

Quoted 22 lines

---
drivers/platform/x86/acer-wmi.c | 6 +++++-

1 file changed, 5 insertions(+), 1 deletion(-)
drivers/platform/x86/acer-wmi.c +5 -1
index e0eaaefb13d0..81d354c80cd2 100644
@@ -1581,7 +1581,11 @@ static int WMI_gaming_execute_u32_u64(u32 method_id, u32 in, u64 *out)
 return -EIO;
 
 obj = result.pointer;
- if (obj && out) {
+ if (!obj) {
+ ret = -ENOMSG;
+ } else if (!out) {
+ ret = -EINVAL;
+ } else {
 switch (obj->type) {

case ACPI_TYPE_INTEGER:
*out = obj->integer.value;

#3 lore raw

PATCH v2 1/1 platform/x86: acer-wmi: reject missing gaming WMI results

In reply to Yousef Alhouseen

WMI_gaming_execute_u32_u64() returns success when firmware supplies no output object, leaving the caller output untouched. Gaming getters then inspect an uninitialized result value.

When the caller requests an output value, return -ENOMSG if firmware supplies no object. Preserve a NULL output pointer as the supported way for callers to ignore the result.

---
Changes in v2:
- Preserve NULL as the supported output-ignore case.
- Only reject a missing firmware object when output was requested.

 drivers/platform/x86/acer-wmi.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/platform/x86/acer-wmi.c +3 -1
index e0eaaefb13d0..61ae622c93d9 100644
@@ -1581,7 +1581,9 @@ static int WMI_gaming_execute_u32_u64(u32 method_id, u32 in, u64 *out)
 		return -EIO;
 
 	obj = result.pointer;
-	if (obj && out) {
+	if (!obj && out) {
+		ret = -ENOMSG;
+	} else if (obj && out) {
 		switch (obj->type) {
 		case ACPI_TYPE_INTEGER:
 			*out = obj->integer.value;
Signature · 1 line
2.55.0
maintainer
#4 lore raw
Quoted 9 lines · Yousef Alhouseen

WMI_gaming_execute_u32_u64() returns success when firmware supplies no output object, leaving the caller output untouched. Gaming getters then inspect an uninitialized result value.

When the caller requests an output value, return -ENOMSG if firmware supplies no object. Preserve a NULL output pointer as the supported way for callers to ignore the result.

Should this have a Fixes tag?

Quoted 24 lines

---
Changes in v2:
- Preserve NULL as the supported output-ignore case.
- Only reject a missing firmware object when output was requested.

 drivers/platform/x86/acer-wmi.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/platform/x86/acer-wmi.c +3 -1
index e0eaaefb13d0..61ae622c93d9 100644
@@ -1581,7 +1581,9 @@ static int WMI_gaming_execute_u32_u64(u32 method_id, u32 in, u64 *out)
 		return -EIO;
 
 	obj = result.pointer;
-	if (obj && out) {
+	if (!obj && out) {
+		ret = -ENOMSG;
+	} else if (obj && out) {
 		switch (obj->type) {
 		case ACPI_TYPE_INTEGER:
 			*out = obj->integer.value;
Signature · 1 line
 i.
#5 lore raw

PATCH v3 1/1 platform/x86: acer-wmi: reject missing gaming WMI results

In reply to Yousef Alhouseen

WMI_gaming_execute_u32_u64() returns success when firmware supplies no output object, leaving the caller output untouched. Gaming getters then inspect an uninitialized result value.

When the caller requests an output value, return -ENOMSG if firmware supplies no object. Preserve a NULL output pointer as the supported way for callers to ignore the result.

Fixes 2d76708c2221 ("platform/x86: acer-wmi: use WMI calls for platform profile handling")

---
Changes in v3:
- Add the Fixes tag requested by Ilpo Järvinen.

Changes in v2:
- Preserve NULL as the supported output-ignore case.
- Only reject a missing firmware object when output was requested.

 drivers/platform/x86/acer-wmi.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/platform/x86/acer-wmi.c +3 -1
index e0eaaefb13d0..61ae622c93d9 100644
@@ -1581,7 +1581,9 @@ static int WMI_gaming_execute_u32_u64(u32 method_id, u32 in, u64 *out)
 		return -EIO;
 
 	obj = result.pointer;
-	if (obj && out) {
+	if (!obj && out) {
+		ret = -ENOMSG;
+	} else if (obj && out) {
 		switch (obj->type) {
 		case ACPI_TYPE_INTEGER:
 			*out = obj->integer.value;
Signature · 1 line
2.55.0
maintainer
#6 lore raw
Quoted 9 lines · Yousef Alhouseen

WMI_gaming_execute_u32_u64() returns success when firmware supplies no output object, leaving the caller output untouched. Gaming getters then inspect an uninitialized result value.

When the caller requests an output value, return -ENOMSG if firmware supplies no object. Preserve a NULL output pointer as the supported way for callers to ignore the result.

[...]

Thank you for your contribution, it has been applied to my local review-ilpo-next branch. Note it will show up in the public platform-drivers-x86/review-ilpo-next branch only once I've pushed my local branch there, which might take a while.

FYI [if applicable to your patch], as per Linus' policy change, also fixes are mostly routed through for-next unless the fix is for a commit introduced in the most recent cycle or is clearly a regression fix.

The list of commits applied:
[1/1] platform/x86: acer-wmi: reject missing gaming WMI results

      commit: caf8342512c3056005f475d350eeca089c3c6623

--
i.