Re: [PATCH] Loongarch64: pci: fix memleak in pci_acpi_scan_root
From: Wentao Guan
Date: Sat Aug 31 2024 - 03:31:29 EST
Hello Huacai:
Okay... It is my code smell, here is the patch after change.
From 73426019a83a77b4502491fc96d145e666b16936 Mon Sep 17 00:00:00 2001
From: Wentao Guan <guanwentao@xxxxxxxxxxxxx>
Date: Sat, 31 Aug 2024 00:17:10 +0800
Subject: [PATCH] Loongarch64: pci: fix memleak in pci_acpi_scan_root
Add kfree(root_ops) in this case to avoid memleak root_ops,
leaks when pci_find_bus() != 0.
Signed-off-by: Wangyuli <wangyuli@xxxxxxxxxxxxx>
Signed-off-by: Wentao Guan <guanwentao@xxxxxxxxxxxxx>
---
arch/loongarch/pci/acpi.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/arch/loongarch/pci/acpi.c b/arch/loongarch/pci/acpi.c
index 3eb61b8cd5e3..f405409a3491 100644
--- a/arch/loongarch/pci/acpi.c
+++ b/arch/loongarch/pci/acpi.c
@@ -227,6 +227,7 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root)
if (bus) {
memcpy(bus->sysdata, info->cfg, sizeof(struct pci_config_window));
kfree(info);
+ kfree(root_ops);
} else {
struct pci_bus *child;
--
2.20.1