From: Florian Fainelli <f.fainelli@gmail.com>
To: Jakub Kicinski <kuba@kernel.org>,
Zhang Changzhong <zhangchangzhong@huawei.com>
Cc: andrew@lunn.ch, hkallweit1@gmail.com, linux@armlinux.org.uk,
davem@davemloft.net, m.felsch@pengutronix.de,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH net] net: phy: smsc: add missed clk_disable_unprepare in smsc_phy_probe()
Date: Sat, 14 Nov 2020 11:45:35 -0800 [thread overview]
Message-ID: <fc03d4de-14d2-1b61-ac9b-40ea26e6fa9a@gmail.com> (raw)
In-Reply-To: <20201114112625.440b52f2@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com>
On 11/14/2020 11:26 AM, Jakub Kicinski wrote:
> On Thu, 12 Nov 2020 19:23:59 +0800 Zhang Changzhong wrote:
>> Add the missing clk_disable_unprepare() before return from
>> smsc_phy_probe() in the error handling case.
>>
>> Fixes: bedd8d78aba3 ("net: phy: smsc: LAN8710/20: add phy refclk in support")
>> Reported-by: Hulk Robot <hulkci@huawei.com>
>> Signed-off-by: Zhang Changzhong <zhangchangzhong@huawei.com>
>> ---
>> drivers/net/phy/smsc.c | 4 +++-
>> 1 file changed, 3 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/net/phy/smsc.c b/drivers/net/phy/smsc.c
>> index ec97669..0fc39ac 100644
>> --- a/drivers/net/phy/smsc.c
>> +++ b/drivers/net/phy/smsc.c
>> @@ -291,8 +291,10 @@ static int smsc_phy_probe(struct phy_device *phydev)
>> return ret;
>>
>> ret = clk_set_rate(priv->refclk, 50 * 1000 * 1000);
>> - if (ret)
>> + if (ret) {
>> + clk_disable_unprepare(priv->refclk);
>> return ret;
>> + }
>>
>> return 0;
>> }
>
> Applied, thanks!
>
> The code right above looks highly questionable as well:
>
> priv->refclk = clk_get_optional(dev, NULL);
> if (IS_ERR(priv->refclk))
> dev_err_probe(dev, PTR_ERR(priv->refclk), "Failed to request clock\n");
>
> ret = clk_prepare_enable(priv->refclk);
> if (ret)
> return ret;
>
> I don't think clk_prepare_enable() will be too happy to see an error
> pointer. This should probably be:
>
> priv->refclk = clk_get_optional(dev, NULL);
> if (IS_ERR(priv->refclk))
> return dev_err_probe(dev, PTR_ERR(priv->refclk),
> "Failed to request clock\n");
Right, especially if EPROBE_DEFER must be returned because the clock
provider is not ready yet, we should have a chance to do that.
--
Florian
next prev parent reply other threads:[~2020-11-14 19:46 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-12 11:23 [PATCH net] net: phy: smsc: add missed clk_disable_unprepare in smsc_phy_probe() Zhang Changzhong
2020-11-14 19:26 ` Jakub Kicinski
2020-11-14 19:45 ` Florian Fainelli [this message]
2020-11-16 9:26 ` Marco Felsch
2020-11-16 17:45 ` Jakub Kicinski
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=fc03d4de-14d2-1b61-ac9b-40ea26e6fa9a@gmail.com \
--to=f.fainelli@gmail.com \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=hkallweit1@gmail.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=m.felsch@pengutronix.de \
--cc=netdev@vger.kernel.org \
--cc=zhangchangzhong@huawei.com \
/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;
as well as URLs for NNTP newsgroup(s).