From: Sakari Ailus Date: Thu, 3 Oct 2019 12:32:08 +0000 (+0300) Subject: software node: Get reference to parent swnode in get_parent op X-Git-Tag: v5.4.15~46 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=3da105401e6f7e7ba77fe412da4bdb5214274611;p=platform%2Fkernel%2Flinux-rpi.git software node: Get reference to parent swnode in get_parent op [ Upstream commit 51c100a651a471fcb8ead1ecc1224471eb0d61b9 ] 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 Reviewed-by: Heikki Krogerus Reviewed-by: Andy Shevchenko Signed-off-by: Rafael J. Wysocki Signed-off-by: Sasha Levin --- diff --git a/drivers/base/swnode.c b/drivers/base/swnode.c index a1f3f09..d5b4905 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 *