[<prev] [next>] [day] [month] [year] [list]
Message-ID: <tencent_E69E39D3C1EAC68651075BCF298FFE81BE07@qq.com>
Date: Thu, 14 Aug 2025 16:24:50 +0800
From: Vencent Liu <961342126@...com>
To: maddy@...ux.ibm.com
Cc: mpe@...erman.id.au,
npiggin@...il.com,
christophe.leroy@...roup.eu,
961342126@...com,
linuxppc-dev@...ts.ozlabs.org,
linux-kernel@...r.kernel.org,
Vencent Liu <Security@...cent.com>
Subject: [PATCH] powerpc: Fix resource leak in ls_uart.c
From: Vencent Liu <Security@...cent.com>
In the ls_uarts_init function, the device node
reference count wasn't properly released on error paths.
When `of_get_property("clock-frequency")`
fails, the function returns `-EINVAL` without calling
`of_node_put(avr)` to release the device node reference obtained by
`of_find_node_by_path()`.
Signed-off-by: Vencent Liu <Security@...cent.com>
---
arch/powerpc/platforms/embedded6xx/ls_uart.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/arch/powerpc/platforms/embedded6xx/ls_uart.c b/arch/powerpc/platforms/embedded6xx/ls_uart.c
index 6c1dbf8ae718..b889206bea4c 100644
--- a/arch/powerpc/platforms/embedded6xx/ls_uart.c
+++ b/arch/powerpc/platforms/embedded6xx/ls_uart.c
@@ -18,6 +18,7 @@
#include <linux/of_address.h>
#include <asm/io.h>
#include <asm/termbits.h>
+#include <linux/cleanup.h>
#include "mpc10x.h"
@@ -114,11 +115,11 @@ static void __init ls_uart_init(void)
static int __init ls_uarts_init(void)
{
- struct device_node *avr;
struct resource res;
int len, ret;
- avr = of_find_node_by_path("/soc10x/serial@...04500");
+ struct device_node *avr __free(device_node) =
+ of_find_node_by_path("/soc10x/serial@...04500");
if (!avr)
return -EINVAL;
--
2.43.5
Powered by blists - more mailing lists