Re: [PATCH 1/3] platform/x86: lenovo-wmi-helpers: Fix memory leak in lwmi_dev_evaluate_int()

From: Ilpo Järvinen

Date: Thu Apr 02 2026 - 06:20:46 EST


On Thu, 2 Apr 2026, Rong Zhang wrote:

> 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.
>
> Fixes: e521d16e76cd ("platform/x86: Add lenovo-wmi-helpers")
> Cc: stable@xxxxxxxxxxxxxxx
> Link: https://sashiko.dev/#/patchset/20260331181208.421552-1-derekjohn.clark%40gmail.com [1]
> Signed-off-by: Rong Zhang <i@xxxxxxxx>
> ---
> drivers/platform/x86/lenovo/wmi-helpers.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/platform/x86/lenovo/wmi-helpers.c b/drivers/platform/x86/lenovo/wmi-helpers.c
> index 7379defac500..80021f59d1ef 100644
> --- a/drivers/platform/x86/lenovo/wmi-helpers.c
> +++ b/drivers/platform/x86/lenovo/wmi-helpers.c
> @@ -55,8 +55,9 @@ int lwmi_dev_evaluate_int(struct wmi_device *wdev, u8 instance, u32 method_id,
> if (ACPI_FAILURE(status))
> return -EIO;
>
> + ret_obj = output.pointer;

To follow the best practice, could you please also place the variable
declaration here as well so there's no separate ret_obj = NULL line.

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

--
i.