mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Liang He <windhl@126.com>
To: zbr@ioremap.net, windhl@126.com, linux-kernel@vger.kernel.org
Subject: [PATCH v2] w1: Add missing of_node_put() and of_node_get()
Date: Wed, 22 Jun 2022 11:42:38 +0800	[thread overview]
Message-ID: <20220622034238.4093806-1-windhl@126.com> (raw)

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


                 reply	other threads:[~2022-06-22  3:42 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220622034238.4093806-1-windhl@126.com \
    --to=windhl@126.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=zbr@ioremap.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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®