lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250428085610.727327-1-qiaozhe@iscas.ac.cn>
Date: Mon, 28 Apr 2025 16:56:10 +0800
From: Zhe Qiao <qiaozhe@...as.ac.cn>
To: qiaozhe@...as.ac.cn,
	rafael@...nel.org,
	lenb@...nel.org,
	bhelgaas@...gle.com
Cc: linux-acpi@...r.kernel.org,
	linux-pci@...r.kernel.org,
	linux-kernel@...r.kernel.org
Subject: [PATCH] ACPI: pci: Release excess memory usage.

In the pci_acpi_scan_root() function, if the PCI bus creation fails,
the allocated memory should be released to avoid memory occupation.

Signed-off-by: Zhe Qiao <qiaozhe@...as.ac.cn>
---
 drivers/pci/pci-acpi.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/drivers/pci/pci-acpi.c b/drivers/pci/pci-acpi.c
index af370628e583..b008dbed7077 100644
--- a/drivers/pci/pci-acpi.c
+++ b/drivers/pci/pci-acpi.c
@@ -1683,9 +1683,7 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root)
 
 	ri->cfg = pci_acpi_setup_ecam_mapping(root);
 	if (!ri->cfg) {
-		kfree(ri);
-		kfree(root_ops);
-		return NULL;
+		goto cleanup_exit;
 	}
 
 	root_ops->release_info = pci_acpi_generic_release_info;
@@ -1693,7 +1691,7 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root)
 	root_ops->pci_ops = (struct pci_ops *)&ri->cfg->ops->pci_ops;
 	bus = acpi_pci_root_create(root, root_ops, &ri->common, ri->cfg);
 	if (!bus)
-		return NULL;
+		goto cleanup_exit;
 
 	/* If we must preserve the resource configuration, claim now */
 	host = pci_find_host_bridge(bus);
@@ -1710,6 +1708,11 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root)
 		pcie_bus_configure_settings(child);
 
 	return bus;
+
+cleanup_exit:
+	kfree(root_ops);
+	kfree(ri);
+	return NULL;
 }
 
 void pcibios_add_bus(struct pci_bus *bus)
-- 
2.43.0


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ