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: <20260130172847.00005bac@huawei.com>
Date: Fri, 30 Jan 2026 17:28:47 +0000
From: Jonathan Cameron <jonathan.cameron@...wei.com>
To: Felix Gu <ustc.gu@...il.com>
CC: Conor Dooley <conor@...nel.org>, Joshua Yeong
	<joshua.yeong@...rfivetech.com>, Conor Dooley <conor.dooley@...rochip.com>,
	<linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] cache: starfive: fix device node leak in
 starlink_cache_init()

On Sat, 31 Jan 2026 01:13:45 +0800
Felix Gu <ustc.gu@...il.com> wrote:

> of_find_matching_node() returns a device_node with refcount incremented.
> 
> Use __free(device_node) attribute to automatically call of_node_put()
> when the variable goes out of scope, preventing the refcount leak.
> 
> Fixes: cabff60ca77d ("cache: Add StarFive StarLink cache management")
> Signed-off-by: Felix Gu <ustc.gu@...il.com>

Indeed a leak that should be fixed and doesn't look like there
can be any access to np from outside of this function, so the fix is good.

Reviewed-by: Jonathan Cameron <jonathan.cameron@...wei.com>


> ---
>  drivers/cache/starfive_starlink_cache.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/cache/starfive_starlink_cache.c b/drivers/cache/starfive_starlink_cache.c
> index 24c7d078ca22..3a25d2d7c70c 100644
> --- a/drivers/cache/starfive_starlink_cache.c
> +++ b/drivers/cache/starfive_starlink_cache.c
> @@ -102,11 +102,11 @@ static const struct of_device_id starlink_cache_ids[] = {
>  
>  static int __init starlink_cache_init(void)
>  {
> -	struct device_node *np;
>  	u32 block_size;
>  	int ret;
>  
> -	np = of_find_matching_node(NULL, starlink_cache_ids);
> +	struct device_node *np __free(device_node) =
> +		of_find_matching_node(NULL, starlink_cache_ids);
>  	if (!of_device_is_available(np))
>  		return -ENODEV;
>  
> 
> ---
> base-commit: 33a647c659ffa5bdb94abc345c8c86768ff96215
> change-id: 20260131-starlink-b23bf5ac7323
> 
> Best regards,


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ