All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
To: Abdun Nihaal <nihaal@cse.iitm.ac.in>
Cc: s.shravan@intel.com, Hans de Goede <hansg@kernel.org>,
	 platform-driver-x86@vger.kernel.org,
	LKML <linux-kernel@vger.kernel.org>,
	 stable@vger.kernel.org
Subject: Re: [PATCH] platform/x86: int1092: Fix potential memory leak in sar_probe()
Date: Thu, 9 Jul 2026 14:31:15 +0300 (EEST)	[thread overview]
Message-ID: <7ae91c3c-4d52-a3ae-e9fb-542fa9002f57@linux.intel.com> (raw)
In-Reply-To: <20260707070524.953741-1-nihaal@cse.iitm.ac.in>

On Tue, 7 Jul 2026, Abdun Nihaal wrote:

> The memory allocated for device_mode_info in parse_package() called by
> sar_get_data() is not freed in some of the error paths in sar_probe().
> Fix that by adding the corresponding free in the error path.
> 
> Fixes: dcfbd31ef4bc ("platform/x86: BIOS SAR driver for Intel M.2 Modem")
> Cc: stable@vger.kernel.org
> Signed-off-by: Abdun Nihaal <nihaal@cse.iitm.ac.in>
> ---
>  drivers/platform/x86/intel/int1092/intel_sar.c | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/platform/x86/intel/int1092/intel_sar.c b/drivers/platform/x86/intel/int1092/intel_sar.c
> index 849f7b415c1e..b27fc07c087a 100644
> --- a/drivers/platform/x86/intel/int1092/intel_sar.c
> +++ b/drivers/platform/x86/intel/int1092/intel_sar.c
> @@ -273,13 +273,13 @@ static int sar_probe(struct platform_device *device)
>  	if (sar_get_device_mode(device) != AE_OK) {
>  		dev_err(&device->dev, "Failed to get device mode\n");
>  		result = -EIO;
> -		goto r_free;
> +		goto r_sar;
>  	}
>  
>  	result = sysfs_create_group(&device->dev.kobj, &intcsar_group);
>  	if (result) {
>  		dev_err(&device->dev, "sysfs creation failed\n");
> -		goto r_free;
> +		goto r_sar;
>  	}
>  
>  	if (acpi_install_notify_handler(ACPI_HANDLE(&device->dev), ACPI_DEVICE_NOTIFY,
> @@ -292,6 +292,9 @@ static int sar_probe(struct platform_device *device)
>  
>  r_sys:
>  	sysfs_remove_group(&device->dev.kobj, &intcsar_group);
> +r_sar:
> +	for (reg = 0; reg < MAX_REGULATORY; reg++)
> +		kfree(context->config_data[reg].device_mode_info);
>  r_free:
>  	kfree(context);

How about try to do this with devm allocs instead (context itself 
included)? I think results would be much better with it.

-- 
 i.


      reply	other threads:[~2026-07-09 11:31 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-07  7:05 [PATCH] platform/x86: int1092: Fix potential memory leak in sar_probe() Abdun Nihaal
2026-07-09 11:31 ` 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=7ae91c3c-4d52-a3ae-e9fb-542fa9002f57@linux.intel.com \
    --to=ilpo.jarvinen@linux.intel.com \
    --cc=hansg@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nihaal@cse.iitm.ac.in \
    --cc=platform-driver-x86@vger.kernel.org \
    --cc=s.shravan@intel.com \
    --cc=stable@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.