Skip to content

Commit

Permalink
platform/x86: mxm-wmi: fix memleak in mxm_wmi_call_mx[ds|mx]()
Browse files Browse the repository at this point in the history
[ Upstream commit 727cc01 ]

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: 99b38b4 ("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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
yuliao0214 authored and gregkh committed Dec 31, 2022
1 parent 6613f36 commit 87426ce
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions drivers/platform/x86/mxm-wmi.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,11 @@ int mxm_wmi_call_mxds(int adapter)
.xarg = 1,
};
struct acpi_buffer input = { (acpi_size)sizeof(args), &args };
struct acpi_buffer output = { ACPI_ALLOCATE_BUFFER, NULL };
acpi_status status;

printk("calling mux switch %d\n", adapter);

status = wmi_evaluate_method(MXM_WMMX_GUID, 0x0, adapter, &input,
&output);
status = wmi_evaluate_method(MXM_WMMX_GUID, 0x0, adapter, &input, NULL);

if (ACPI_FAILURE(status))
return status;
Expand All @@ -60,13 +58,11 @@ int mxm_wmi_call_mxmx(int adapter)
.xarg = 1,
};
struct acpi_buffer input = { (acpi_size)sizeof(args), &args };
struct acpi_buffer output = { ACPI_ALLOCATE_BUFFER, NULL };
acpi_status status;

printk("calling mux switch %d\n", adapter);

status = wmi_evaluate_method(MXM_WMMX_GUID, 0x0, adapter, &input,
&output);
status = wmi_evaluate_method(MXM_WMMX_GUID, 0x0, adapter, &input, NULL);

if (ACPI_FAILURE(status))
return status;
Expand Down

0 comments on commit 87426ce

Please sign in to comment.