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] [day] [month] [year] [list]
Message-ID: <CAL_JsqJBcKf-EMAYvnXJDB4izoyk9s-8SUn4CAUm3qatd6Yrzg@mail.gmail.com>
Date: Mon, 29 Sep 2025 10:14:21 -0500
From: Rob Herring <robh@...nel.org>
To: Ma Ke <make24@...as.ac.cn>
Cc: saravanak@...gle.com, lizhi.hou@....com, devicetree@...r.kernel.org, 
	linux-kernel@...r.kernel.org, akpm@...ux-foundation.org, 
	stable@...r.kernel.org
Subject: Re: [PATCH RESEND] of: unittest: Fix device reference count leak in of_unittest_pci_node_verify

On Sun, Sep 28, 2025 at 10:47 PM Ma Ke <make24@...as.ac.cn> wrote:
>
> In of_unittest_pci_node_verify(), when the add parameter is false,
> device_find_any_child() obtains a reference to a child device. This
> function implicitly calls get_device() to increment the device's
> reference count before returning the pointer. However, the caller
> fails to properly release this reference by calling put_device(),
> leading to a device reference count leak.
>
> As the comment of device_find_any_child states: "NOTE: you will need
> to drop the reference with put_device() after use".

Please implement my review comments on the last version you sent.

>
> Cc: stable@...r.kernel.org
> Fixes: 26409dd04589 ("of: unittest: Add pci_dt_testdrv pci driver")
> Signed-off-by: Ma Ke <make24@...as.ac.cn>
> ---
>  drivers/of/unittest.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/of/unittest.c b/drivers/of/unittest.c
> index e3503ec20f6c..d225e73781fe 100644
> --- a/drivers/of/unittest.c
> +++ b/drivers/of/unittest.c
> @@ -4271,7 +4271,7 @@ static struct platform_driver unittest_pci_driver = {
>  static int of_unittest_pci_node_verify(struct pci_dev *pdev, bool add)
>  {
>         struct device_node *pnp, *np = NULL;
> -       struct device *child_dev;
> +       struct device *child_dev = NULL;
>         char *path = NULL;
>         const __be32 *reg;
>         int rc = 0;
> @@ -4306,6 +4306,8 @@ static int of_unittest_pci_node_verify(struct pci_dev *pdev, bool add)
>         kfree(path);
>         if (np)
>                 of_node_put(np);
> +       if (child_dev)
> +               put_device(child_dev);
>
>         return rc;
>  }
> --
> 2.17.1
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ