Unverified Commit 0c3887a1 authored by Rong Zhang's avatar Rong Zhang Committed by Ilpo Järvinen
Browse files

platform/x86: lenovo-wmi-helpers: Fix memory leak in lwmi_dev_evaluate_int()



lwmi_dev_evaluate_int() leaks output.pointer when retval == NULL (found
by sashiko.dev [1]).

Fix it by moving `ret_obj = output.pointer' outside of the `if (retval)'
block so that it is always freed by the __free cleanup callback.

No functional change intended.

Reviewed-by: default avatarMark Pearson <mpearson-lenovo@squebb.ca>
Fixes: e521d16e ("platform/x86: Add lenovo-wmi-helpers")
Cc: stable@vger.kernel.org
Link: https://sashiko.dev/#/patchset/20260331181208.421552-1-derekjohn.clark%40gmail.com

 [1]
Signed-off-by: default avatarRong Zhang <i@rong.moe>
Signed-off-by: default avatarDerek J. Clark <derekjohn.clark@gmail.com>
Link: https://patch.msgid.link/20260510042546.436874-2-derekjohn.clark@gmail.com


Reviewed-by: default avatarIlpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: default avatarIlpo Järvinen <ilpo.jarvinen@linux.intel.com>
parent a59e4522
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -46,7 +46,6 @@ int lwmi_dev_evaluate_int(struct wmi_device *wdev, u8 instance, u32 method_id,
			  unsigned char *buf, size_t size, u32 *retval)
{
	struct acpi_buffer output = { ACPI_ALLOCATE_BUFFER, NULL };
	union acpi_object *ret_obj __free(kfree) = NULL;
	struct acpi_buffer input = { size, buf };
	acpi_status status;

@@ -55,8 +54,9 @@ int lwmi_dev_evaluate_int(struct wmi_device *wdev, u8 instance, u32 method_id,
	if (ACPI_FAILURE(status))
		return -EIO;

	union acpi_object *ret_obj __free(kfree) = output.pointer;

	if (retval) {
		ret_obj = output.pointer;
		if (!ret_obj)
			return -ENODATA;