[v9,01/12] software node: Get reference to parent swnode in get_parent op
diff mbox series

Message ID 20191003123219.11237-2-sakari.ailus@linux.intel.com
State Awaiting Upstream
Delegated to: Rafael Wysocki
Headers show
  • Device property improvements, add %pfw format specifier
Related show

Commit Message

Sakari Ailus Oct. 3, 2019, 12:32 p.m. UTC
The software_node_get_parent() returned a pointer to the parent swnode,
but did not take a reference to it, leading the caller to put a reference
that was not taken. Take that reference now.

Fixes: 59abd83672f7 ("drivers: base: Introducing software nodes to the firmware node framework")
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
 drivers/base/swnode.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff mbox series

diff --git a/drivers/base/swnode.c b/drivers/base/swnode.c
index e7b3aa3bd55ad..a7cb41812cfda 100644
--- a/drivers/base/swnode.c
+++ b/drivers/base/swnode.c
@@ -520,7 +520,10 @@  software_node_get_parent(const struct fwnode_handle *fwnode)
 	struct swnode *swnode = to_swnode(fwnode);
-	return swnode ? (swnode->parent ? &swnode->parent->fwnode : NULL) : NULL;
+	if (!swnode || !swnode->parent)
+		return NULL;
+	return fwnode_handle_get(&swnode->parent->fwnode);
 static struct fwnode_handle *