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-next>] [day] [month] [year] [list]
Date:   Tue,  7 Jun 2022 07:00:55 +0400
From:   Miaoqian Lin <linmq006@...il.com>
To:     Nicolas Ferre <nicolas.ferre@...rochip.com>,
        Alexandre Belloni <alexandre.belloni@...tlin.com>,
        Claudiu Beznea <claudiu.beznea@...rochip.com>,
        Miaoqian Lin <linmq006@...il.com>,
        Mihai Sain <mihai.sain@...rochip.com>,
        Sudeep Holla <sudeep.holla@....com>,
        linux-arm-kernel@...ts.infradead.org, linux-kernel@...r.kernel.org
Subject: [PATCH v2] drivers: soc: atmel: Fix refcount leak in atmel_soc_device_init

of_find_node_by_path() returns a node pointer with refcount incremented,
we should use of_node_put() on it when not need anymore.
Add missing of_node_put() to avoid refcount leak.

Fixes: 960ddf70cc11 ("drivers: soc: atmel: Avoid calling at91_soc_init on non AT91 SoCs")
Signed-off-by: Miaoqian Lin <linmq006@...il.com>
---
changes in v2:
- create new variable match to refactor the patch.

v1 Link: https://lore.kernel.org/r/20220605084035.27127-1-linmq006@gmail.com
---
 drivers/soc/atmel/soc.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/soc/atmel/soc.c b/drivers/soc/atmel/soc.c
index b2d365ae0282..7152a38c657a 100644
--- a/drivers/soc/atmel/soc.c
+++ b/drivers/soc/atmel/soc.c
@@ -368,8 +368,11 @@ static const struct of_device_id at91_soc_allowed_list[] __initconst = {
 static int __init atmel_soc_device_init(void)
 {
 	struct device_node *np = of_find_node_by_path("/");
+	const struct of_device_id *match;
 
-	if (!of_match_node(at91_soc_allowed_list, np))
+	match = of_match_node(at91_soc_allowed_list, np);
+	of_node_put(np);
+	if (!match)
 		return 0;
 
 	at91_soc_init(socs);
-- 
2.25.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ