diff mbox series

[RFC,v1,24/30] platform/x86: wmi: do not fail if disabling fails

Message ID 20210904175450.156801-25-pobrn@protonmail.com (mailing list archive)
State Accepted, archived
Headers show
Series platform/x86: wmi: minor improvements | expand

Commit Message

Barnabás Pőcze Sept. 4, 2021, 5:56 p.m. UTC
Previously, `__query_block()` would fail if the
second WCxx method call failed. However, the
WQxx method might have succeded, and potentially
allocated memory for the result. Instead of
throwing away the result and potentially
leaking memory, ignore the result of
the second WCxx call.

Signed-off-by: Barnabás Pőcze <pobrn@protonmail.com>
---
 drivers/platform/x86/wmi.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

--
2.33.0
diff mbox series

Patch

diff --git a/drivers/platform/x86/wmi.c b/drivers/platform/x86/wmi.c
index ec5ba2970840..5929d9d26801 100644
--- a/drivers/platform/x86/wmi.c
+++ b/drivers/platform/x86/wmi.c
@@ -352,7 +352,14 @@  static acpi_status __query_block(struct wmi_block *wblock, u8 instance,
 	 * the WQxx method failed - we should disable collection anyway.
 	 */
 	if ((block->flags & ACPI_WMI_EXPENSIVE) && ACPI_SUCCESS(wc_status)) {
-		status = acpi_execute_simple_method(handle, wc_method, 0);
+		/*
+		 * Ignore whether this WCxx call succeeds or not since
+		 * the previously executed WQxx method call might have
+		 * succeeded, and returning the failing status code
+		 * of this call would throw away the result of the WQxx
+		 * call, potentially leaking memory.
+		 */
+		acpi_execute_simple_method(handle, wc_method, 0);
 	}

 	return status;