Subject: Re: [PATCH (net.git)] stmmac: ptp: fix the reference clock

From: Giuseppe CAVALLARO <[email-masked]>
Date: Thu, 28 Aug 2014 08:02:10 +0200

Hi David

On 8/28/2014 1:26 AM, David Miller wrote:
> From: Giuseppe Cavallaro <[email-masked]>
> Date: Tue, 26 Aug 2014 08:04:32 +0200
>
>> @@ -638,6 +638,15 @@ static int stmmac_init_ptp(struct stmmac_priv *priv)
>>   	if (!(priv->dma_cap.time_stamp || priv->dma_cap.atime_stamp))
>>   		return -EOPNOTSUPP;
>>
>> +	/* Fall-back to main clock in case of no PTP ref is passed */
>> +	priv->clk_ptp_ref = devm_clk_get(priv->device, "clk_ptp_ref");
>> +	if (IS_ERR(priv->clk_ptp_ref)) {
>> +		priv->clk_ptp_rate = clk_get_rate(priv->stmmac_clk);
>
> This code path will leave an IS_ERR() value in clk_ptp_ref.
>   ...
>>   static void stmmac_release_ptp(struct stmmac_priv *priv)
>>   {
>> +	if (priv->clk_ptp_ref)
>> +		clk_disable_unprepare(priv->clk_ptp_ref);
>>   	stmmac_ptp_unregister(priv);
>>   }
>
> Which this code will erroneously pass into clk_disable_unprepare().
>
> Please NULL the pointer out properl when devm_clk_get() errors.

I had sent the v2, let me know if it's ok for you.

peppe

> Thanks.