mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Krzysztof Kozlowski <krzk@kernel.org>
To: Jacky Liu <1972843537@qq.com>, davem@davemloft.net
Cc: andreas@gaisler.com, sparclinux@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] arch: fix resource leak in chmc.c
Date: Fri, 18 Jul 2025 15:25:47 +0200	[thread overview]
Message-ID: <25e7455e-816c-448a-b78b-94fe9437e3c8@kernel.org> (raw)
In-Reply-To: <tencent_C3DEC6F98F25C1BF6F35F3A1B0A629E0EA0A@qq.com>

On 18/07/2025 11:22, Jacky Liu wrote:
> From: Siyang Liu <1972843537@qq.com>
> 
> In the jbusmc_probe function, the device node mem_node fetched 
> via of_find_node_by_path("/memory") is not properly freed 
> on all code paths. 
> This can lead to leakage of device node reference counts, 
> which may result in kernel resources not being released.
> 
> This issue was detected by rule based static tools 
> developed by Tencent.


Last time you were using AI, so I have doubts this is "static tools".
Please describe it properly, so we can make informed decision whether to
allocate time on this.

> 
> Signed-off-by: Siyang Liu <1972843537@qq.com>
> ---
>  arch/sparc/kernel/chmc.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/sparc/kernel/chmc.c b/arch/sparc/kernel/chmc.c
> index d4c74d6b2e1b..a7040ee7e5bc 100644
> --- a/arch/sparc/kernel/chmc.c
> +++ b/arch/sparc/kernel/chmc.c
> @@ -4,6 +4,7 @@
>   * Copyright (C) 2001, 2007, 2008 David S. Miller (davem@davemloft.net)
>   */
>  
> +#include <linux/cleanup.h>
>  #include <linux/module.h>
>  #include <linux/kernel.h>
>  #include <linux/types.h>
> @@ -397,14 +398,14 @@ static void jbusmc_construct_dimm_groups(struct jbusmc *p,
>  static int jbusmc_probe(struct platform_device *op)
>  {
>  	const struct linux_prom64_registers *mem_regs;
> -	struct device_node *mem_node;
> +	struct device_node *mem_node __free(device_node) =
> +			of_find_node_by_path("/memory");


Nah, just free it immediately after user. Don't over complicate this.


Best regards,
Krzysztof

  reply	other threads:[~2025-07-18 13:25 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-18  9:22 Jacky Liu
2025-07-18 13:25 ` Krzysztof Kozlowski [this message]
2025-07-21  2:04   ` jackysliu
2025-07-18 13:43 ` [PATCH] " Markus Elfring
2025-07-21  3:57   ` [PATCH v2] arch: fix resource leak in jbusmc_probe() jackysliu
2025-07-21  7:18     ` Markus Elfring
2025-07-21  7:55       ` [PATCH v3] sparc: " jackysliu
2025-07-21  8:17         ` Markus Elfring
2025-07-22  6:22         ` Krzysztof Kozlowski
2025-07-21  8:25     ` [PATCH v2] arch: " Krzysztof Kozlowski

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=25e7455e-816c-448a-b78b-94fe9437e3c8@kernel.org \
    --to=krzk@kernel.org \
    --cc=1972843537@qq.com \
    --cc=andreas@gaisler.com \
    --cc=davem@davemloft.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sparclinux@vger.kernel.org \
    /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

all inboxes | Powered by JetHome®