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-prev] [thread-next>] [day] [month] [year] [list]
Date:   Wed, 17 Apr 2019 10:44:53 +0800
From:   Wen Yang <wen.yang99@....com.cn>
To:     linux-kernel@...r.kernel.org
Cc:     wang.yi59@....com.cn, Wen Yang <wen.yang99@....com.cn>,
        Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        Alan Tull <atull@...nel.org>,
        Richard Gong <richard.gong@...el.com>,
        Nicolas Saenz Julienne <nsaenzjulienne@...e.de>
Subject: [PATCH 3/3] firmware: stratix10-svc: fix leaked of_node references

In stratix10_svc_init function, fw_np is obtained by calling
of_find_node_by_name(), np is obtained by calling
of_find_matching_node(), and the reference counts of those
two device_nodes, fw_np and np, are increased.
But when the function exits, only of_node_put is called on np,
and fw_np's reference count is leaked.

Detected by coccinelle with the following warnings:
./drivers/firmware/stratix10-svc.c:1020:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 1014, but without a corresponding object release within this function.
./drivers/firmware/stratix10-svc.c:1025:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 1014, but without a corresponding object release within this function.
./drivers/firmware/stratix10-svc.c:1027:1-7: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 1014, but without a corresponding object release within this function.

Signed-off-by: Wen Yang <wen.yang99@....com.cn>
Cc: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
Cc: Alan Tull <atull@...nel.org>
Cc: Richard Gong <richard.gong@...el.com>
Cc: Nicolas Saenz Julienne <nsaenzjulienne@...e.de>
Cc: linux-kernel@...r.kernel.org
---
 drivers/firmware/stratix10-svc.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/drivers/firmware/stratix10-svc.c b/drivers/firmware/stratix10-svc.c
index 6e65148..482a6bd 100644
--- a/drivers/firmware/stratix10-svc.c
+++ b/drivers/firmware/stratix10-svc.c
@@ -1016,15 +1016,21 @@ static int __init stratix10_svc_init(void)
 		return -ENODEV;
 
 	np = of_find_matching_node(fw_np, stratix10_svc_drv_match);
-	if (!np)
-		return -ENODEV;
+	if (!np) {
+		ret = -ENODEV;
+		goto out_put_fw_np;
+	}
 
 	of_node_put(np);
 	ret = of_platform_populate(fw_np, stratix10_svc_drv_match, NULL, NULL);
 	if (ret)
-		return ret;
+		goto out_put_fw_np;
 
-	return platform_driver_register(&stratix10_svc_driver);
+	ret = platform_driver_register(&stratix10_svc_driver);
+
+out_put_fw_np:
+	of_node_put(fw_np);
+	return ret;
 }
 
 static void __exit stratix10_svc_exit(void)
-- 
2.9.5

Powered by blists - more mailing lists