Linux ACPI
 help / color / mirror / Atom feed
From: Bjorn Helgaas <helgaas@kernel.org>
To: Nirmoy Das <nirmoyd@nvidia.com>
Cc: linux-acpi@vger.kernel.org, Bjorn Helgaas <bhelgaas@google.com>,
	"Rafael J . Wysocki" <rafael@kernel.org>,
	Len Brown <lenb@kernel.org>, Vidya Sagar <vidyas@nvidia.com>,
	linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] ACPI/PCI: Fix memory leak fix in pci_acpi_preserve_config
Date: Mon, 25 Aug 2025 17:37:31 -0500	[thread overview]
Message-ID: <20250825223731.GA808746@bhelgaas> (raw)
In-Reply-To: <20250825214642.142135-1-nirmoyd@nvidia.com>

On Mon, Aug 25, 2025 at 02:46:42PM -0700, Nirmoy Das wrote:
> The pci_acpi_preserve_config() function is leaking memory by returning
> early without freeing the ACPI object on success. Fix that by always
> freeing the obj which is not needed by the caller.
> 
> Fixes: 9d7d5db8e78e ("PCI: Move PRESERVE_BOOT_CONFIG _DSM evaluation to pci_register_host_bridge()")
> Signed-off-by: Nirmoy Das <nirmoyd@nvidia.com>

Applied to pci/misc for v6.18, thanks!

> ---
>  drivers/pci/pci-acpi.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/pci/pci-acpi.c b/drivers/pci/pci-acpi.c
> index ddb25960ea47d..9369377725fa0 100644
> --- a/drivers/pci/pci-acpi.c
> +++ b/drivers/pci/pci-acpi.c
> @@ -122,6 +122,8 @@ phys_addr_t acpi_pci_root_get_mcfg_addr(acpi_handle handle)
>  
>  bool pci_acpi_preserve_config(struct pci_host_bridge *host_bridge)
>  {
> +	bool ret = false;
> +
>  	if (ACPI_HANDLE(&host_bridge->dev)) {
>  		union acpi_object *obj;
>  
> @@ -135,11 +137,11 @@ bool pci_acpi_preserve_config(struct pci_host_bridge *host_bridge)
>  					      1, DSM_PCI_PRESERVE_BOOT_CONFIG,
>  					      NULL, ACPI_TYPE_INTEGER);
>  		if (obj && obj->integer.value == 0)
> -			return true;
> +			ret = true;
>  		ACPI_FREE(obj);
>  	}
>  
> -	return false;
> +	return ret;
>  }
>  
>  /* _HPX PCI Setting Record (Type 0); same as _HPP */
> -- 
> 2.43.0
> 

  reply	other threads:[~2025-08-25 22:37 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-25 21:46 [PATCH] ACPI/PCI: Fix memory leak fix in pci_acpi_preserve_config Nirmoy Das
2025-08-25 22:37 ` Bjorn Helgaas [this message]
2025-08-27 10:21   ` Nirmoy Das

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=20250825223731.GA808746@bhelgaas \
    --to=helgaas@kernel.org \
    --cc=bhelgaas@google.com \
    --cc=lenb@kernel.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=nirmoyd@nvidia.com \
    --cc=rafael@kernel.org \
    --cc=vidyas@nvidia.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