Skip to content

Commit fac679d

Browse files
nirmoybjorn-helgaas
authored andcommitted
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: 9d7d5db ("PCI: Move PRESERVE_BOOT_CONFIG _DSM evaluation to pci_register_host_bridge()") Signed-off-by: Nirmoy Das <[email protected]> Signed-off-by: Bjorn Helgaas <[email protected]> Link: https://patch.msgid.link/[email protected]
1 parent 8f5ae30 commit fac679d

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

drivers/pci/pci-acpi.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,8 @@ phys_addr_t acpi_pci_root_get_mcfg_addr(acpi_handle handle)
122122

123123
bool pci_acpi_preserve_config(struct pci_host_bridge *host_bridge)
124124
{
125+
bool ret = false;
126+
125127
if (ACPI_HANDLE(&host_bridge->dev)) {
126128
union acpi_object *obj;
127129

@@ -135,11 +137,11 @@ bool pci_acpi_preserve_config(struct pci_host_bridge *host_bridge)
135137
1, DSM_PCI_PRESERVE_BOOT_CONFIG,
136138
NULL, ACPI_TYPE_INTEGER);
137139
if (obj && obj->integer.value == 0)
138-
return true;
140+
ret = true;
139141
ACPI_FREE(obj);
140142
}
141143

142-
return false;
144+
return ret;
143145
}
144146

145147
/* _HPX PCI Setting Record (Type 0); same as _HPP */

0 commit comments

Comments
 (0)