[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <25e7455e-816c-448a-b78b-94fe9437e3c8@kernel.org>
Date: Fri, 18 Jul 2025 15:25:47 +0200
From: Krzysztof Kozlowski <krzk@...nel.org>
To: Jacky Liu <1972843537@...com>, davem@...emloft.net
Cc: andreas@...sler.com, sparclinux@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH] arch: fix resource leak in chmc.c
On 18/07/2025 11:22, Jacky Liu wrote:
> From: Siyang Liu <1972843537@...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@...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@...emloft.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
Powered by blists - more mailing lists