of/address: Don't loop forever in of_find_matching_node_by_address().
PATCH 1/1 of/address: Don't loop forever in of_find_matching_node_by_address().
From: David Daney <david.daney-YGCgFSpz5w/[email protected]>
If the internal call to of_address_to_resource() fails, we end up looping forever in of_find_matching_node_by_address(). This can be caused by a defective device tree, or calling with an incorrect matches argument.
Fix by calling of_find_matching_node() unconditionally at the end of the loop.
--- drivers/of/address.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/of/address.c +3 -3
@@ -845,10 +845,10 @@ struct device_node *of_find_matching_node_by_address(struct device_node *from,struct resource res;while (dn) { -if (of_address_to_resource (dn,0 , &res)) -continue ; -if (res.start == base_address) +if (!of_address_to_resource (dn,0 , &res) && + res.start == base_address)return dn; + dn =of_find_matching_node (dn, matches); }
Signature · 6 lines
1.9.1 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 11 lines · David Daney
From: David Daney <[email protected]>
If the internal call to
of_address_to_resource()fails, we end up looping forever inof_find_matching_node_by_address(). This can be caused by a defective device tree, or calling with an incorrect matches argument.Fix by calling
of_find_matching_node()unconditionally at the end of the loop.Signed-off-by David Daney <[email protected]>
Applied and tagged for stable. Thanks.
Rob
Quoted 25 lines
--- drivers/of/address.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)drivers/of/address.c +3
-4@@ -845,10 +845,10 @@ struct device_node *of_find_matching_node_by_address(struct device_node *from,struct resource res;while (dn) { -if (of_address_to_resource (dn,0 , &res)) -continue ; -if (res.start == base_address) +if (!of_address_to_resource (dn,0 , &res) && + res.start == base_address)return dn; + dn =of_find_matching_node (dn, matches); } --1.9.1