X86 platform drivers
 help / color / mirror / Atom feed
From: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
To: yahia <yahia.a.abdrabou@gmail.com>
Cc: platform-driver-x86@vger.kernel.org
Subject: Re: [PATCH 1/3] hp-wmi: refactor to use __free
Date: Mon, 13 Jul 2026 14:21:20 +0300 (EEST)	[thread overview]
Message-ID: <d5341fb7-25d4-e746-38a1-552e36f829cf@linux.intel.com> (raw)
In-Reply-To: <20260712191130.41183-2-yahia.a.abdrabou@gmail.com>

On Sun, 12 Jul 2026, yahia wrote:

> From: yahia ahmed <yahia.a.abdrabou@gmail.com>
> 
> hp_wmi_query_perform currently() uses the out_free label to exit the
> function and free the memory, but doesn't use the __free cleanup

__free()

More generally, please include () into names which are directly 
referencing a C function name, macro, etc. that have parenthesis in their 
name in C as well.

> attribute to simply the processes of exiting and freeing memory.
> 
> Signed-off-by: yahia ahmed <yahia.a.abdrabou@gmail.com>
> ---
>  drivers/platform/x86/hp/hp-wmi.c | 20 +++++++-------------
>  1 file changed, 7 insertions(+), 13 deletions(-)
> 
> diff --git a/drivers/platform/x86/hp/hp-wmi.c b/drivers/platform/x86/hp/hp-wmi.c
> index 8ba286ed8721..c924fbb5503f 100644
> --- a/drivers/platform/x86/hp/hp-wmi.c
> +++ b/drivers/platform/x86/hp/hp-wmi.c
> @@ -581,8 +581,8 @@ static int hp_wmi_perform_query(int query, enum hp_wmi_command command,
>  {
>  	struct acpi_buffer input, output = { ACPI_ALLOCATE_BUFFER, NULL };
>  	struct bios_return *bios_return;
> -	union acpi_object *obj = NULL;
> -	struct bios_args *args = NULL;
> +	union acpi_object *obj __free(kfree) = NULL;
> +	struct bios_args *args __free(kfree) = NULL;
>  	int mid, actual_insize, actual_outsize;
>  	size_t bios_args_size;
>  	int ret;
> @@ -608,18 +608,16 @@ static int hp_wmi_perform_query(int query, enum hp_wmi_command command,
>  
>  	ret = wmi_evaluate_method(HPWMI_BIOS_GUID, 0, mid, &input, &output);
>  	if (ret)
> -		goto out_free;
> +		return ret;
>  
>  	obj = output.pointer;
>  	if (!obj) {
> -		ret = -EINVAL;
> -		goto out_free;
> +		return -EINVAL;
>  	}
>  
>  	if (obj->type != ACPI_TYPE_BUFFER) {
>  		pr_warn("query 0x%x returned an invalid object 0x%x\n", query, ret);
> -		ret = -EINVAL;
> -		goto out_free;
> +		return -EINVAL;
>  	}
>  
>  	bios_return = (struct bios_return *)obj->buffer.pointer;
> @@ -629,20 +627,16 @@ static int hp_wmi_perform_query(int query, enum hp_wmi_command command,
>  		if (ret != HPWMI_RET_UNKNOWN_COMMAND &&
>  		    ret != HPWMI_RET_UNKNOWN_CMDTYPE)
>  			pr_warn("query 0x%x returned error 0x%x\n", query, ret);
> -		goto out_free;
> +		return ret;
>  	}
>  
>  	/* Ignore output data of zero size */
>  	if (!outsize)
> -		goto out_free;
> +		return ret;
>  
>  	actual_outsize = min(outsize, (int)(obj->buffer.length - sizeof(*bios_return)));
>  	memcpy(buffer, obj->buffer.pointer + sizeof(*bios_return), actual_outsize);
>  	memset(buffer + actual_outsize, 0, outsize - actual_outsize);
> -
> -out_free:
> -	kfree(obj);
> -	kfree(args);
>  	return ret;

Can't this now be return 0; ?

-- 
 i.


  reply	other threads:[~2026-07-13 11:21 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-12 19:11 [PATCH 0/3]: hp-wmi: fix various issues with yahia
2026-07-12 19:11 ` [PATCH 1/3] hp-wmi: refactor to use __free yahia
2026-07-13 11:21   ` Ilpo Järvinen [this message]
2026-07-12 19:11 ` [PATCH 2/3] hp-wmi: fix potential integer underflow yahia
2026-07-13 11:23   ` Ilpo Järvinen
2026-07-13 12:24     ` yahia
2026-07-12 19:11 ` [PATCH 3/3] hp-wmi: move from kmalloc to kzalloc yahia
2026-07-13 11:30   ` Ilpo Järvinen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=d5341fb7-25d4-e746-38a1-552e36f829cf@linux.intel.com \
    --to=ilpo.jarvinen@linux.intel.com \
    --cc=platform-driver-x86@vger.kernel.org \
    --cc=yahia.a.abdrabou@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox