* [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
* Re: [PATCH] ACPI/PCI: Fix memory leak fix in pci_acpi_preserve_config
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
0 siblings, 1 reply; 3+ messages in thread
From: Bjorn Helgaas @ 2025-08-25 22:37 UTC (permalink / raw)
To: Nirmoy Das
Cc: linux-acpi, Bjorn Helgaas, Rafael J . Wysocki, Len Brown,
Vidya Sagar, linux-pci, linux-kernel
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
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] ACPI/PCI: Fix memory leak fix in pci_acpi_preserve_config
2025-08-25 22:37 ` Bjorn Helgaas
@ 2025-08-27 10:21 ` Nirmoy Das
0 siblings, 0 replies; 3+ messages in thread
From: Nirmoy Das @ 2025-08-27 10:21 UTC (permalink / raw)
To: Bjorn Helgaas
Cc: linux-acpi, Bjorn Helgaas, Rafael J . Wysocki, Len Brown,
Vidya Sagar, linux-pci, linux-kernel
On 26.08.25 00:37, Bjorn Helgaas wrote:
> 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!
Thanks Bjorn!
>
>> ---
>> 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 [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).