Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

platform/x86: mxm-wmi: fix memleak in mxm_wmi_call_mx[ds|mx]()

The ACPI buffer memory (out.pointer) returned by wmi_evaluate_method()
is not freed after the call, so it leads to memory leak.

The method results in ACPI buffer is not used, so just pass NULL to
wmi_evaluate_method() which fixes the memory leak.

Fixes: 99b38b4acc0d ("platform/x86: add MXM WMI driver.")
Signed-off-by: Yu Liao <liaoyu15@huawei.com>
Link: https://lore.kernel.org/r/20221129011101.2042315-1-liaoyu15@huawei.com
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>

authored by

Yu Liao and committed by
Hans de Goede
727cc014 b03ae77e

+2 -6
+2 -6
drivers/platform/x86/mxm-wmi.c
··· 35 35 .xarg = 1, 36 36 }; 37 37 struct acpi_buffer input = { (acpi_size)sizeof(args), &args }; 38 - struct acpi_buffer output = { ACPI_ALLOCATE_BUFFER, NULL }; 39 38 acpi_status status; 40 39 41 40 printk("calling mux switch %d\n", adapter); 42 41 43 - status = wmi_evaluate_method(MXM_WMMX_GUID, 0x0, adapter, &input, 44 - &output); 42 + status = wmi_evaluate_method(MXM_WMMX_GUID, 0x0, adapter, &input, NULL); 45 43 46 44 if (ACPI_FAILURE(status)) 47 45 return status; ··· 58 60 .xarg = 1, 59 61 }; 60 62 struct acpi_buffer input = { (acpi_size)sizeof(args), &args }; 61 - struct acpi_buffer output = { ACPI_ALLOCATE_BUFFER, NULL }; 62 63 acpi_status status; 63 64 64 65 printk("calling mux switch %d\n", adapter); 65 66 66 - status = wmi_evaluate_method(MXM_WMMX_GUID, 0x0, adapter, &input, 67 - &output); 67 + status = wmi_evaluate_method(MXM_WMMX_GUID, 0x0, adapter, &input, NULL); 68 68 69 69 if (ACPI_FAILURE(status)) 70 70 return status;