lkml.org 
[lkml]   [2018]   [Dec]   [3]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] w1: fix wrong dt refcount in attach slave device
Date
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
\
 
 \ /
  Last update: 2018-12-03 13:21    [W:0.034 / U:0.644 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site