[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20221121064049.1173345-1-yangyingliang@huawei.com>
Date: Mon, 21 Nov 2022 14:40:49 +0800
From: Yang Yingliang <yangyingliang@...wei.com>
To: <linux-acpi@...r.kernel.org>, <linux-kernel@...r.kernel.org>
CC: <andriy.shevchenko@...ux.intel.com>, <djrscally@...il.com>,
<heikki.krogerus@...ux.intel.com>, <sakari.ailus@...ux.intel.com>,
<gregkh@...uxfoundation.org>, <rafael@...nel.org>
Subject: [PATCH] device property: fix of node refcount leak in fwnode_graph_get_next_endpoint()
The 'parent' returned by fwnode_graph_get_port_parent() with refcount
incremented when prev is not null, it needs be put when finish using
it.
Fixes: b5b41ab6b0c1 ("device property: Check fwnode->secondary in fwnode_graph_get_next_endpoint()")
Signed-off-by: Yang Yingliang <yangyingliang@...wei.com>
---
drivers/base/property.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/drivers/base/property.c b/drivers/base/property.c
index 2a5a37fcd998..022d4ff366be 100644
--- a/drivers/base/property.c
+++ b/drivers/base/property.c
@@ -1005,10 +1005,16 @@ fwnode_graph_get_next_endpoint(const struct fwnode_handle *fwnode,
return NULL;
ep = fwnode_call_ptr_op(parent, graph_get_next_endpoint, prev);
- if (ep)
+ if (ep) {
+ if (prev)
+ fwnode_handle_put((struct fwnode_handle *)parent);
return ep;
+ }
- return fwnode_graph_get_next_endpoint(parent->secondary, NULL);
+ ep = fwnode_graph_get_next_endpoint(parent->secondary, NULL);
+ if (prev)
+ fwnode_handle_put((struct fwnode_handle *)parent);
+ return ep;
}
EXPORT_SYMBOL_GPL(fwnode_graph_get_next_endpoint);
--
2.25.1
Powered by blists - more mailing lists