lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAAhV-H7GptUdpKScV1AuZZm7w-F5oUXHRmaT9BFCZV4HuQExJg@mail.gmail.com>
Date: Sat, 31 Aug 2024 15:18:44 +0800
From: Huacai Chen <chenhuacai@...nel.org>
To: Wentao Guan <guanwentao@...ontech.com>
Cc: henhuacai@...nel.org, kernel@...0n.name, loongarch@...ts.linux.dev, 
	linux-kernel@...r.kernel.org, Wangyuli <wangyuli@...ontech.com>
Subject: Re: [PATCH] Loongarch64: pci: fix memleak in pci_acpi_scan_root

Hi, Wentao,

On Sat, Aug 31, 2024 at 1:24 PM Wentao Guan <guanwentao@...ontech.com> wrote:
>
> Add kfree(root_ops) in this case to avoid memleak root_ops,
> leaks when pci_find_bus() != 0.
> Also delay assign root_ops when used for making code read clean.
> Found by code review
>
> Signed-off-by: Wangyuli <wangyuli@...ontech.com>
This should be Yuli Wang <wangyuli@...ontech.com>

> Signed-off-by: Wentao Guan <guanwentao@...ontech.com>
> ---
>  arch/loongarch/pci/acpi.c | 9 +++++----
>  1 file changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/arch/loongarch/pci/acpi.c b/arch/loongarch/pci/acpi.c
> index 3eb61b8cd5e3..7f3539f5fa23 100644
> --- a/arch/loongarch/pci/acpi.c
> +++ b/arch/loongarch/pci/acpi.c
> @@ -219,17 +219,18 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root)
>                 return NULL;
>         }
>
> -       root_ops->release_info = acpi_release_root_info;
> -       root_ops->prepare_resources = acpi_prepare_root_resources;
> -       root_ops->pci_ops = (struct pci_ops *)&info->cfg->ops->pci_ops;
> -
>         bus = pci_find_bus(domain, busnum);
>         if (bus) {
>                 memcpy(bus->sysdata, info->cfg, sizeof(struct pci_config_window));
>                 kfree(info);
> +               kfree(root_ops);
Add kfree() is fine, but move root_ops assignment is unnecessary.

Huacai

>         } else {
>                 struct pci_bus *child;
>
> +               root_ops->release_info = acpi_release_root_info;
> +               root_ops->prepare_resources = acpi_prepare_root_resources;
> +               root_ops->pci_ops = (struct pci_ops *)&info->cfg->ops->pci_ops;
> +
>                 bus = acpi_pci_root_create(root, root_ops,
>                                            &info->common, info->cfg);
>                 if (!bus) {
> --
> 2.20.1
>
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ