From: "Wentao Guan" <guanwentao@uniontech.com>
To: "Huacai Chen" <chenhuacai@kernel.org>
Cc: "WANG Xuerui" <kernel@xen0n.name>,
loongarch <loongarch@lists.linux.dev>,
linux-kernel <linux-kernel@vger.kernel.org>,
王昱力 <wangyuli@uniontech.com>
Subject: Re: [PATCH] Loongarch64: pci: fix memleak in pci_acpi_scan_root
Date: Sat, 31 Aug 2024 15:30:10 +0800 [thread overview]
Message-ID: <tencent_3F6931DF7E765EB870FD970A@qq.com> (raw)
In-Reply-To: <CAAhV-H7GptUdpKScV1AuZZm7w-F5oUXHRmaT9BFCZV4HuQExJg@mail.gmail.com>
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@uniontech.com>
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@uniontech.com>
Signed-off-by: Wentao Guan <guanwentao@uniontech.com>
---
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
next prev parent reply other threads:[~2024-08-31 7:30 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-31 5:21 [PATCH] Loongarch64: pci: fix memleak in pci_acpi_scan_root Wentao Guan
2024-08-31 7:18 ` Huacai Chen
2024-08-31 7:30 ` Wentao Guan [this message]
2024-08-31 8:35 ` Wentao Guan
2024-08-31 12:37 ` Huacai Chen
2024-08-31 7:40 ` WangYuli
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=tencent_3F6931DF7E765EB870FD970A@qq.com \
--to=guanwentao@uniontech.com \
--cc=chenhuacai@kernel.org \
--cc=kernel@xen0n.name \
--cc=linux-kernel@vger.kernel.org \
--cc=loongarch@lists.linux.dev \
--cc=wangyuli@uniontech.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.