* [PATCH v2] w1: Add missing of_node_put() and of_node_get()
@ 2022-06-22 3:42 Liang He
0 siblings, 0 replies; only message in thread
From: Liang He @ 2022-06-22 3:42 UTC (permalink / raw)
To: zbr, windhl, linux-kernel
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@126.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
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-06-22 3:42 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-22 3:42 [PATCH v2] w1: Add missing of_node_put() and of_node_get() Liang He
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®