mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
To: Yousef Alhouseen <alhouseenyousef@gmail.com>
Cc: "David E . Box" <david.e.box@linux.intel.com>,
	 Hans de Goede <hansg@kernel.org>,
	platform-driver-x86@vger.kernel.org,
	 LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] platform/x86/intel/vsec: free ACPI discovery data on early errors
Date: Fri, 3 Jul 2026 14:40:56 +0300 (EEST)	[thread overview]
Message-ID: <0a324545-ea70-742b-88a6-3e2338fa8b24@linux.intel.com> (raw)
In-Reply-To: <20260629160415.29280-1-alhouseenyousef@gmail.com>

On Mon, 29 Jun 2026, Yousef Alhouseen wrote:

> intel_vsec_add_dev() may attach an ACPI discovery table copy to the
> intel_vsec_device before passing ownership to intel_vsec_add_aux(). The
> normal auxiliary-device release path frees that copy, but the earliest
> intel_vsec_add_aux() failures free only the outer structure directly.
> 
> Route those direct frees through a common helper so acpi_disc is
> released consistently on the parent, xarray, and ID allocation failure
> paths.
> 
> Signed-off-by: Yousef Alhouseen <alhouseenyousef@gmail.com>

Shouldn't this have a Fixes tag?

--
 i.

> ---
>  drivers/platform/x86/intel/vsec.c | 17 ++++++++++++-----
>  1 file changed, 12 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/platform/x86/intel/vsec.c b/drivers/platform/x86/intel/vsec.c
> index 3ae4557b32b4..5ab2215fdd7f 100644
> --- a/drivers/platform/x86/intel/vsec.c
> +++ b/drivers/platform/x86/intel/vsec.c
> @@ -103,6 +103,12 @@ static void intel_vsec_remove_aux(void *data)
>  	auxiliary_device_uninit(data);
>  }
>  
> +static void intel_vsec_dev_free(struct intel_vsec_device *intel_vsec_dev)
> +{
> +	kfree(intel_vsec_dev->acpi_disc);
> +	kfree(intel_vsec_dev);
> +}
> +
>  static void intel_vsec_dev_release(struct device *dev)
>  {
>  	struct intel_vsec_device *intel_vsec_dev = dev_to_ivdev(dev);
> @@ -111,8 +117,7 @@ static void intel_vsec_dev_release(struct device *dev)
>  
>  	ida_free(intel_vsec_dev->ida, intel_vsec_dev->auxdev.id);
>  
> -	kfree(intel_vsec_dev->acpi_disc);
> -	kfree(intel_vsec_dev);
> +	intel_vsec_dev_free(intel_vsec_dev);
>  }
>  
>  static const struct vsec_feature_dependency *
> @@ -218,20 +223,22 @@ int intel_vsec_add_aux(struct device *parent,
>  	struct auxiliary_device *auxdev = &intel_vsec_dev->auxdev;
>  	int ret, id;
>  
> -	if (!parent)
> +	if (!parent) {
> +		intel_vsec_dev_free(intel_vsec_dev);
>  		return -EINVAL;
> +	}
>  
>  	ret = xa_alloc(&auxdev_array, &intel_vsec_dev->id, intel_vsec_dev,
>  		       PMT_XA_LIMIT, GFP_KERNEL);
>  	if (ret < 0) {
> -		kfree(intel_vsec_dev);
> +		intel_vsec_dev_free(intel_vsec_dev);
>  		return ret;
>  	}
>  
>  	id = ida_alloc(intel_vsec_dev->ida, GFP_KERNEL);
>  	if (id < 0) {
>  		xa_erase(&auxdev_array, intel_vsec_dev->id);
> -		kfree(intel_vsec_dev);
> +		intel_vsec_dev_free(intel_vsec_dev);
>  		return id;
>  	}
>  
> 

      reply	other threads:[~2026-07-03 11:41 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-29 16:04 Yousef Alhouseen
2026-07-03 11:40 ` Ilpo Järvinen [this message]

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=0a324545-ea70-742b-88a6-3e2338fa8b24@linux.intel.com \
    --to=ilpo.jarvinen@linux.intel.com \
    --cc=alhouseenyousef@gmail.com \
    --cc=david.e.box@linux.intel.com \
    --cc=hansg@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=platform-driver-x86@vger.kernel.org \
    /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