Re: [PATCH] soc: qcom: geni: Fix NULL pointer dereference

From: Matthias Kaehlcke
Date: Fri Jul 17 2020 - 10:48:45 EST


Please make sure to cc the linux-arm-msm@vger list for patches of
Qualcomm code.

On Fri, Jul 17, 2020 at 08:02:22PM +0530, Akash Asthana wrote:
> pdev struct doesn't exits for the devices whose status are disabled

s/exits/exist/

> 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@xxxxxxxxxxxxxx>
> Signed-off-by: Akash Asthana <akashast@xxxxxxxxxxxxxx>
> ---
> 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;

nit: since there is no other 'pdev' in this function you could just name
it 'pdev', which is less clunky. The variable is only used immediately
after it is assigned, so it's clear from the context that it refers to
the 'wrapper'.

Reviewed-by: Matthias Kaehlcke <mka@xxxxxxxxxxxx>