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>] [day] [month] [year] [list]
Date: Sun,  7 Apr 2024 10:22:12 -0400
From: Wenyu Huang <huangwenyuu@...look.com>
To: robh@...nel.org
Cc: linux-kernel@...r.kernel.org
Subject: [drivers/virt] Eliminate uses of of_node_put

Convert the DT code to use __free() based cleanups for
of_node_put(). Using __free() simplifies function exit
handling.

Signed-off-by: Wenyu Huang <huangwenyuu@...look.com>
---
 drivers/virt/fsl_hypervisor.c | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/drivers/virt/fsl_hypervisor.c b/drivers/virt/fsl_hypervisor.c
index e92e2ceb12a4..5a5c7a767a98 100644
--- a/drivers/virt/fsl_hypervisor.c
+++ b/drivers/virt/fsl_hypervisor.c
@@ -725,12 +725,11 @@ static irqreturn_t fsl_hv_shutdown_isr(int irq, void *data)
  */
 static int get_parent_handle(struct device_node *np)
 {
-	struct device_node *parent;
+	struct device_node *parent __free(device_node) = of_get_parent(np);
 	const uint32_t *prop;
 	uint32_t handle;
 	int len;
 
-	parent = of_get_parent(np);
 	if (!parent)
 		/* It's not really possible for this to fail */
 		return -ENODEV;
@@ -745,12 +744,10 @@ static int get_parent_handle(struct device_node *np)
 
 	if (!prop || (len != sizeof(uint32_t))) {
 		/* This can happen only if the node is malformed */
-		of_node_put(parent);
 		return -ENODEV;
 	}
 
 	handle = be32_to_cpup(prop);
-	of_node_put(parent);
 
 	return handle;
 }
@@ -789,17 +786,14 @@ EXPORT_SYMBOL(fsl_hv_failover_unregister);
  */
 static int has_fsl_hypervisor(void)
 {
-	struct device_node *node;
+	struct device_node *node __free(device_node) = of_find_node_by_path("/hypervisor");
 	int ret;
 
-	node = of_find_node_by_path("/hypervisor");
 	if (!node)
 		return 0;
 
 	ret = of_property_present(node, "fsl,hv-version");
 
-	of_node_put(node);
-
 	return ret;
 }
 
-- 
2.34.1


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ