public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Jonathan Cameron <jonathan.cameron@huawei.com>
To: Felix Gu <ustc.gu@gmail.com>
Cc: Conor Dooley <conor@kernel.org>,
	Joshua Yeong <joshua.yeong@starfivetech.com>,
	Conor Dooley <conor.dooley@microchip.com>,
	<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] cache: starfive: fix device node leak in starlink_cache_init()
Date: Fri, 30 Jan 2026 17:28:47 +0000	[thread overview]
Message-ID: <20260130172847.00005bac@huawei.com> (raw)
In-Reply-To: <20260131-starlink-v1-1-30985722d51f@gmail.com>

On Sat, 31 Jan 2026 01:13:45 +0800
Felix Gu <ustc.gu@gmail.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@gmail.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@huawei.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,


  reply	other threads:[~2026-01-30 17:28 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-30 17:13 [PATCH] cache: starfive: fix device node leak in starlink_cache_init() Felix Gu
2026-01-30 17:28 ` Jonathan Cameron [this message]
2026-02-06 20:28 ` Conor Dooley

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=20260130172847.00005bac@huawei.com \
    --to=jonathan.cameron@huawei.com \
    --cc=conor.dooley@microchip.com \
    --cc=conor@kernel.org \
    --cc=joshua.yeong@starfivetech.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ustc.gu@gmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox