soc: qcom: smsm: fix child-node lookup
authorJohan Hovold <johan@kernel.org>
Wed, 15 Nov 2017 11:07:24 +0000 (12:07 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 24 Mar 2018 10:01:27 +0000 (11:01 +0100)
[ Upstream commit 8804517e9fc16c10081ff5e42e7d80704973a8e2 ]

Fix child-node lookup during probe, which ended up searching the whole
device tree depth-first starting at the parent rather than just matching
on its children.

Note that the original premature free of the parent node has already
been fixed separately.

Also note that this pattern of looking up the first child node with a
given property is rare enough that a generic helper is probably not
warranted.

Fixes: c97c4090ff72 ("soc: qcom: smsm: Add driver for Qualcomm SMSM")
Fixes: 3e8b55411468 ("soc: qcom: smsm: fix of_node refcnting problem")
Cc: Bjorn Andersson <bjorn.andersson@linaro.org>
Cc: Rob Clark <robdclark@gmail.com>
Signed-off-by: Johan Hovold <johan@kernel.org>
Reviewed-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Signed-off-by: Andy Gross <andy.gross@linaro.org>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/soc/qcom/smsm.c

index 403bea9d546bbc947eaa5cbbe22bd3a974668980..50214b620865e70fd438b8dd3ef0bc4bfa2d9beb 100644 (file)
@@ -496,8 +496,10 @@ static int qcom_smsm_probe(struct platform_device *pdev)
        if (!smsm->hosts)
                return -ENOMEM;
 
-       local_node = of_find_node_with_property(of_node_get(pdev->dev.of_node),
-                                               "#qcom,smem-state-cells");
+       for_each_child_of_node(pdev->dev.of_node, local_node) {
+               if (of_find_property(local_node, "#qcom,smem-state-cells", NULL))
+                       break;
+       }
        if (!local_node) {
                dev_err(&pdev->dev, "no state entry\n");
                return -EINVAL;