linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
To: Evgeniy Polyakov <zbr@ioremap.net>
Cc: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>,
	linux-kernel@vger.kernel.org
Subject: [PATCH] w1: fix wrong dt refcount in attach slave device
Date: Mon,  3 Dec 2018 13:19:51 +0100	[thread overview]
Message-ID: <20181203121951.1230-1-nsaenzjulienne@suse.de> (raw)

With each call to of_find_matching_node() we're decresing the reference
count on the master's dt node. This is not what we actually want. So we
get a refernce to the dt node before calling it.

Fixes: fae68031f7fbc ("w1: core: match sub-nodes of bus masters in devicetree")
Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
---
 drivers/w1/w1.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/w1/w1.c b/drivers/w1/w1.c
index 890c038c25f8..09514fa6c6b9 100644
--- a/drivers/w1/w1.c
+++ b/drivers/w1/w1.c
@@ -680,15 +680,17 @@ static int w1_family_notify(unsigned long action, struct w1_slave *sl)
 
 static int __w1_attach_slave_device(struct w1_slave *sl)
 {
+	struct device_node *np;
 	int err;
 
+	np = of_node_get(sl->master->dev.of_node);
+
 	sl->dev.parent = &sl->master->dev;
 	sl->dev.driver = &w1_slave_driver;
 	sl->dev.bus = &w1_bus_type;
 	sl->dev.release = &w1_slave_release;
 	sl->dev.groups = w1_slave_groups;
-	sl->dev.of_node = of_find_matching_node(sl->master->dev.of_node,
-						sl->family->of_match_table);
+	sl->dev.of_node = of_find_matching_node(np, sl->family->of_match_table);
 
 	dev_set_name(&sl->dev, "%02x-%012llx",
 		 (unsigned int) sl->reg_num.family,
-- 
2.19.2


                 reply	other threads:[~2018-12-03 12:20 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=20181203121951.1230-1-nsaenzjulienne@suse.de \
    --to=nsaenzjulienne@suse.de \
    --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;
as well as URLs for NNTP newsgroup(s).