diff options
author | Daniel Scally <djrscally@gmail.com> | 2021-01-07 14:28:24 +0100 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2021-03-04 10:26:22 +0100 |
commit | 69e859a9d0a46d49f5ba1a7828c8040f3813014e (patch) | |
tree | bfd3d7a771ff684eadfa119cb91308c5c1561a85 /drivers/base | |
parent | 1e0f565138dba1149fb6a57fd817904ae269c73f (diff) |
media: software_node: Fix refcounts in software_node_get_next_child()
[ Upstream commit fb5ec981adf08b94e6ce27ca16b7765c94f4513c ]
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@linux.intel.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Daniel Scally <djrscally@gmail.com>
Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'drivers/base')
-rw-r--r-- | drivers/base/swnode.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/drivers/base/swnode.c b/drivers/base/swnode.c index 77cc138d138c..7d5236eafe84 100644 --- a/drivers/base/swnode.c +++ b/drivers/base/swnode.c @@ -534,14 +534,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 * |