Subject: [PATCH] clk: Do not dereference potential NULL pointer

From: [email-masked] (Stephen Boyd)
Date: Thu, 31 Oct 2013 10:12:32 -0700

On 10/31/13 05:03, Thierry Reding wrote:
> A NULL pointer may be passed to _clk_register() for the dev parameter
> (via clk_register()). Make sure not to dereference it before checking
> that it's valid.
>
> Signed-off-by: Thierry Reding <[email-masked]>
> ---

Ugh I had this fixed but didn't send it.

Acked-by: Stephen Boyd <[email-masked]>

>  drivers/clk/clk.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
> index b68a999..c0b52e3 100644
> --- a/drivers/clk/clk.c
> +++ b/drivers/clk/clk.c
> @@ -1976,7 +1976,7 @@ static int _clk_register(struct device *dev, struct clk_hw *hw, struct clk *clk)
>  		hw->regmap = hw->init->regmap;
>  	else if (dev && dev_get_regmap(dev, NULL))
>  		hw->regmap = dev_get_regmap(dev, NULL);
> -	else if (dev->parent)
> +	else if (dev && dev->parent)
>  		hw->regmap = dev_get_regmap(dev->parent, NULL);
>  
>  	/* allocate local copy in case parent_names is __initdata */

-- 
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
hosted by The Linux Foundation