[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <175932920385.1497002.3410181800952961448.robh@kernel.org>
Date: Wed, 1 Oct 2025 09:33:24 -0500
From: "Rob Herring (Arm)" <robh@...nel.org>
To: Ma Ke <make24@...as.ac.cn>
Cc: lizhi.hou@....com, linux-kernel@...r.kernel.org,
devicetree@...r.kernel.org, akpm@...ux-foundation.org,
stable@...r.kernel.org, saravanak@...gle.com
Subject: Re: [PATCH v2] of: unittest: Fix device reference count leak in
of_unittest_pci_node_verify
On Tue, 30 Sep 2025 16:16:18 +0800, Ma Ke 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. Add put_device() in the else
> branch immediately after child_dev is no longer needed.
>
> As the comment of device_find_any_child states: "NOTE: you will need
> to drop the reference with put_device() after use".
>
> Found by code review.
>
> Cc: stable@...r.kernel.org
> Fixes: 26409dd04589 ("of: unittest: Add pci_dt_testdrv pci driver")
> Signed-off-by: Ma Ke <make24@...as.ac.cn>
> ---
> Changes in v2:
> - modified the put_device() location as suggestions.
> ---
> drivers/of/unittest.c | 1 +
> 1 file changed, 1 insertion(+)
>
Applied, thanks!
Powered by blists - more mailing lists