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]
Message-Id: <20220622034238.4093806-1-windhl@126.com>
Date:   Wed, 22 Jun 2022 11:42:38 +0800
From:   Liang He <windhl@....com>
To:     zbr@...emap.net, windhl@....com, linux-kernel@...r.kernel.org
Subject: [PATCH v2] w1: Add missing of_node_put() and of_node_get()

In __w1_attach_slave_device(), we need to add the of_node_put() for
the reference returned by of_find_matching_node() in fail path.

Besides, we will also need a of_node_get() for the first argument of
of_find_matching_node() which will decrease its refcount.

Signed-off-by: Liang He <windhl@....com>
---
 changelog:

 v2: add missing put and get
 v1: only add missing put

 drivers/w1/w1.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/w1/w1.c b/drivers/w1/w1.c
index f2ae2e563dc5..378996d947cc 100644
--- a/drivers/w1/w1.c
+++ b/drivers/w1/w1.c
@@ -680,6 +680,8 @@ static int __w1_attach_slave_device(struct w1_slave *sl)
 	sl->dev.bus = &w1_bus_type;
 	sl->dev.release = &w1_slave_release;
 	sl->dev.groups = w1_slave_groups;
+
+	of_node_get(sl->master->dev.of_node);
 	sl->dev.of_node = of_find_matching_node(sl->master->dev.of_node,
 						sl->family->of_match_table);
 
@@ -702,6 +704,7 @@ static int __w1_attach_slave_device(struct w1_slave *sl)
 		dev_err(&sl->dev,
 			"Device registration [%s] failed. err=%d\n",
 			dev_name(&sl->dev), err);
+		of_node_put(sl->dev.of_node);
 		put_device(&sl->dev);
 		return err;
 	}
-- 
2.25.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ