Commit 84ee7f89 authored by Johan Hovold's avatar Johan Hovold Committed by Greg Kroah-Hartman

drm/msm: fix OF child-node lookup

commit f9a70823 upstream.

Use the new of_get_compatible_child() helper to lookup the legacy
pwrlevels child node instead of using of_find_compatible_node(), which
searches the entire tree from a given start node and thus can return an
unrelated (i.e.  non-child) node.

This also addresses a potential use-after-free (e.g. after probe
deferral) as the tree-wide helper drops a reference to its first
argument (i.e. the probed device's node).

While at it, also fix the related child-node reference leak.

Fixes: e2af8b6b ("drm/msm: gpu: Use OPP tables if we can")
Cc: stable <stable@vger.kernel.org>     # 4.12
Cc: Jordan Crouse <jcrouse@codeaurora.org>
Cc: Rob Clark <robdclark@gmail.com>
Cc: David Airlie <airlied@linux.ie>
Signed-off-by: default avatarJohan Hovold <johan@kernel.org>
Signed-off-by: default avatarRob Herring <robh@kernel.org>
[ johan: backport to 4.14 ]
Signed-off-by: default avatarJohan Hovold <johan@kernel.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent b002e9dc
...@@ -223,8 +223,7 @@ static int adreno_get_legacy_pwrlevels(struct device *dev) ...@@ -223,8 +223,7 @@ static int adreno_get_legacy_pwrlevels(struct device *dev)
struct device_node *child, *node; struct device_node *child, *node;
int ret; int ret;
node = of_find_compatible_node(dev->of_node, NULL, node = of_get_compatible_child(dev->of_node, "qcom,gpu-pwrlevels");
"qcom,gpu-pwrlevels");
if (!node) { if (!node) {
dev_err(dev, "Could not find the GPU powerlevels\n"); dev_err(dev, "Could not find the GPU powerlevels\n");
return -ENXIO; return -ENXIO;
...@@ -245,6 +244,8 @@ static int adreno_get_legacy_pwrlevels(struct device *dev) ...@@ -245,6 +244,8 @@ static int adreno_get_legacy_pwrlevels(struct device *dev)
dev_pm_opp_add(dev, val, 0); dev_pm_opp_add(dev, val, 0);
} }
of_node_put(node);
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment