mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Bjorn Andersson <bjorn.andersson@linaro.org>
To: Akash Asthana <akashast@codeaurora.org>
Cc: mka@chromium.org, linux-kernel@vger.kernel.org,
	saipraka@codeaurora.org, msavaliy@codeaurora.org
Subject: Re: [PATCH] soc: qcom: geni: Fix NULL pointer dereference
Date: Mon, 20 Jul 2020 13:12:47 -0700	[thread overview]
Message-ID: <20200720201247.GI1218486@builder.lan> (raw)
In-Reply-To: <1594996342-26964-1-git-send-email-akashast@codeaurora.org>

On Fri 17 Jul 07:32 PDT 2020, Akash Asthana wrote:

> 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.
> 
> Fixes: 048eb908a1f2 ("soc: qcom-geni-se: Add interconnect support to fix earlycon crash")
> Reported-by: Sai Prakash Ranjan <saipraka@codeaurora.org>
> Signed-off-by: Akash Asthana <akashast@codeaurora.org>

Reviewed-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Tested-by: Bjorn Andersson <bjorn.andersson@linaro.org>

And applied with Matthias suggested rename of wrapper_pdev to pdev.


PS. Please include linux-arm-msm@vger.kernel.org among your recipients
for future patches.

Regards,
Bjorn

> ---
>  drivers/soc/qcom/qcom-geni-se.c | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/soc/qcom/qcom-geni-se.c b/drivers/soc/qcom/qcom-geni-se.c
> index 355d503..6e5fe65 100644
> --- a/drivers/soc/qcom/qcom-geni-se.c
> +++ b/drivers/soc/qcom/qcom-geni-se.c
> @@ -820,6 +820,7 @@ void geni_remove_earlycon_icc_vote(void)
>  	struct geni_wrapper *wrapper;
>  	struct device_node *parent;
>  	struct device_node *child;
> +	struct platform_device *wrapper_pdev;
>  
>  	if (!earlycon_wrapper)
>  		return;
> @@ -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));
> +
> +		wrapper_pdev = of_find_device_by_node(child);
> +		if (!wrapper_pdev)
> +			continue;
> +
> +		wrapper = platform_get_drvdata(wrapper_pdev);
>  		icc_put(wrapper->to_core.path);
>  		wrapper->to_core.path = NULL;
>  
> -- 
> The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,\na Linux Foundation Collaborative Project
> 

      parent reply	other threads:[~2020-07-20 20:14 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-17 14:32 Akash Asthana
2020-07-17 14:48 ` Matthias Kaehlcke
2020-07-20  9:01   ` Akash Asthana
2020-07-20 20:12 ` Bjorn Andersson [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200720201247.GI1218486@builder.lan \
    --to=bjorn.andersson@linaro.org \
    --cc=akashast@codeaurora.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mka@chromium.org \
    --cc=msavaliy@codeaurora.org \
    --cc=saipraka@codeaurora.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome