[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20201224010907.263125-2-djrscally@gmail.com>
Date: Thu, 24 Dec 2020 01:08:54 +0000
From: Daniel Scally <djrscally@...il.com>
To: linux-kernel@...r.kernel.org, linux-acpi@...r.kernel.org,
linux-media@...r.kernel.org, devel@...ica.org
Cc: rjw@...ysocki.net, lenb@...nel.org, gregkh@...uxfoundation.org,
yong.zhi@...el.com, sakari.ailus@...ux.intel.com,
bingbu.cao@...el.com, tian.shu.qiu@...el.com, mchehab@...nel.org,
robert.moore@...el.com, erik.kaneda@...el.com, pmladek@...e.com,
rostedt@...dmis.org, sergey.senozhatsky@...il.com,
andriy.shevchenko@...ux.intel.com, linux@...musvillemoes.dk,
laurent.pinchart+renesas@...asonboard.com,
jacopo+renesas@...ndi.org, kieran.bingham+renesas@...asonboard.com,
hverkuil-cisco@...all.nl, m.felsch@...gutronix.de,
niklas.soderlund+renesas@...natech.se, slongerbeam@...il.com,
heikki.krogerus@...ux.intel.com, linus.walleij@...aro.org,
Laurent Pinchart <laurent.pinchart@...asonboard.com>
Subject: [PATCH v3 01/14] software_node: Fix refcounts in software_node_get_next_child()
The software_node_get_next_child() function currently does not hold
references to the child software_node that it finds or put the ref that
is held against the old child - fix that.
Fixes: 59abd83672f7 ("drivers: base: Introducing software nodes to the firmware node framework")
Reviewed-by: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@...asonboard.com>
Reviewed-by: Sakari Ailus <sakari.ailus@...ux.intel.com>
Signed-off-by: Daniel Scally <djrscally@...il.com>
---
Changes in v3
- None
drivers/base/swnode.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/drivers/base/swnode.c b/drivers/base/swnode.c
index 010828fc785b..615a0c93e116 100644
--- a/drivers/base/swnode.c
+++ b/drivers/base/swnode.c
@@ -443,14 +443,18 @@ software_node_get_next_child(const struct fwnode_handle *fwnode,
struct swnode *c = to_swnode(child);
if (!p || list_empty(&p->children) ||
- (c && list_is_last(&c->entry, &p->children)))
+ (c && list_is_last(&c->entry, &p->children))) {
+ fwnode_handle_put(child);
return NULL;
+ }
if (c)
c = list_next_entry(c, entry);
else
c = list_first_entry(&p->children, struct swnode, entry);
- return &c->fwnode;
+
+ fwnode_handle_put(child);
+ return fwnode_handle_get(&c->fwnode);
}
static struct fwnode_handle *
--
2.25.1
Powered by blists - more mailing lists