[PATCH net-next v2 1/4] of: property: skip links without a consumer node

James Hilliard <[email protected]>
Newsgroups gmane.linux.network,gmane.linux.drivers.devicetree,gmane.linux.kernel
Message-ID <20260816-submit-phy-package-fwdevlink-v1-v2-1-23e55dd59fad@gmail.com>
Supplier bindings can map a property node to the device node which
consumes the referenced resource. The remote-endpoint binding uses
of_graph_get_port_parent(), which can return NULL for a malformed graph
node without its expected parents.

of_link_property() currently passes that NULL node through to
fwnode_link_add(), which dereferences the consumer while adding the
link.

Only create the link when the binding resolved a consumer node. A
malformed graph property then creates no dependency instead of crashing
while fw_devlink parses the tree.

Fixes: f7514a663016 ("of: property: fw_devlink: Add support for remote-endpoint")
Signed-off-by: James Hilliard <[email protected]>
---
 drivers/of/property.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/of/property.c b/drivers/of/property.c
index 72cf12907de0..38c0c7dc428a 100644
--- a/drivers/of/property.c
+++ b/drivers/of/property.c
@@ -1620,7 +1620,9 @@ static int of_link_property(struct device_node *con_np, const char *prop_name)
 
 			matched = true;
 			i++;
-			of_link_to_phandle(con_dev_np, phandle, s->fwlink_flags);
+			if (con_dev_np)
+				of_link_to_phandle(con_dev_np, phandle,
+						   s->fwlink_flags);
 			of_node_put(phandle);
 		}
 		s++;

-- 
2.53.0
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.