[PATCH v2 4/4] software node: pin remote endpoint swnode
From: Peng Fan (OSS)
Date: Thu Nov 05 2026 - 23:35:04 EST
From: Peng Fan <peng.fan@xxxxxxx>
software_node_graph_get_remote_endpoint() looks up the referenced node
with software_node_fwnode() and then takes a reference with
software_node_get(). The borrowed pointer can be released in between.
Use software_node_to_swnode_get() directly and return the fwnode with
the acquired reference retained.
Signed-off-by: Peng Fan <peng.fan@xxxxxxx>
---
drivers/base/swnode.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/drivers/base/swnode.c b/drivers/base/swnode.c
index 1b0ecd3e814f9..e7c57cfb277c6 100644
--- a/drivers/base/swnode.c
+++ b/drivers/base/swnode.c
@@ -696,6 +696,7 @@ software_node_graph_get_remote_endpoint(const struct fwnode_handle *fwnode)
{
struct swnode *swnode = to_swnode(fwnode);
const struct software_node_ref_args *ref;
+ struct swnode *remote;
const struct property_entry *prop;
if (!swnode)
@@ -710,7 +711,11 @@ software_node_graph_get_remote_endpoint(const struct fwnode_handle *fwnode)
if (!ref->swnode)
return NULL;
- return software_node_get(software_node_fwnode(ref->swnode));
+ remote = software_node_to_swnode_get(ref->swnode);
+ if (!remote)
+ return NULL;
+
+ return &remote->fwnode;
}
static struct fwnode_handle *
--
2.34.1