linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ACPI/PCI: Fix memory leak fix in pci_acpi_preserve_config
@ 2025-08-25 21:46 Nirmoy Das
  2025-08-25 22:37 ` Bjorn Helgaas
  0 siblings, 1 reply; 3+ messages in thread
From: Nirmoy Das @ 2025-08-25 21:46 UTC (permalink / raw)
  To: linux-acpi
  Cc: Bjorn Helgaas, Rafael J . Wysocki, Len Brown, Vidya Sagar,
	linux-pci, linux-kernel, nirmoyd

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>
---
 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


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-08-27 10:23 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
2025-08-27 10:21   ` Nirmoy Das

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).