Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

PCI/ACPI: Fix pci_acpi_preserve_config() memory leak

pci_acpi_preserve_config() leaks 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>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Link: https://patch.msgid.link/20250825214642.142135-1-nirmoyd@nvidia.com

authored by

Nirmoy Das and committed by
Bjorn Helgaas
fac679df 8f5ae30d

+4 -2
+4 -2
drivers/pci/pci-acpi.c
··· 122 122 123 123 bool pci_acpi_preserve_config(struct pci_host_bridge *host_bridge) 124 124 { 125 + bool ret = false; 126 + 125 127 if (ACPI_HANDLE(&host_bridge->dev)) { 126 128 union acpi_object *obj; 127 129 ··· 137 135 1, DSM_PCI_PRESERVE_BOOT_CONFIG, 138 136 NULL, ACPI_TYPE_INTEGER); 139 137 if (obj && obj->integer.value == 0) 140 - return true; 138 + ret = true; 141 139 ACPI_FREE(obj); 142 140 } 143 141 144 - return false; 142 + return ret; 145 143 } 146 144 147 145 /* _HPX PCI Setting Record (Type 0); same as _HPP */