Commit 03c900b3 authored by Akash Asthana's avatar Akash Asthana Committed by Bjorn Andersson

soc: qcom: geni: Fix NULL pointer dereference

pdev struct doesn't exits for the devices whose status are disabled
from DT node, in such cases NULL is returned from 'of_find_device_by_node'
Later when we try to get drvdata from pdev struct NULL pointer dereference
is triggered.

Add a NULL check for return values to fix the issue.

We were hitting this issue when one of QUP is disabled.
Reviewed-by: default avatarMatthias Kaehlcke <mka@chromium.org>
Reviewed-by: default avatarBjorn Andersson <bjorn.andersson@linaro.org>
Tested-by: default avatarBjorn Andersson <bjorn.andersson@linaro.org>
Fixes: 048eb908 ("soc: qcom-geni-se: Add interconnect support to fix earlycon crash")
Reported-by: default avatarSai Prakash Ranjan <saipraka@codeaurora.org>
Signed-off-by: default avatarAkash Asthana <akashast@codeaurora.org>
Link: https://lore.kernel.org/r/1594996342-26964-1-git-send-email-akashast@codeaurora.org
[bjorn: s/wrapper_pdev/pdev/]
Signed-off-by: default avatarBjorn Andersson <bjorn.andersson@linaro.org>
parent 4a3107f6
......@@ -817,6 +817,7 @@ EXPORT_SYMBOL(geni_icc_disable);
void geni_remove_earlycon_icc_vote(void)
{
struct platform_device *pdev;
struct geni_wrapper *wrapper;
struct device_node *parent;
struct device_node *child;
......@@ -829,7 +830,12 @@ void geni_remove_earlycon_icc_vote(void)
for_each_child_of_node(parent, child) {
if (!of_device_is_compatible(child, "qcom,geni-se-qup"))
continue;
wrapper = platform_get_drvdata(of_find_device_by_node(child));
pdev = of_find_device_by_node(child);
if (!pdev)
continue;
wrapper = platform_get_drvdata(pdev);
icc_put(wrapper->to_core.path);
wrapper->to_core.path = NULL;
......
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