Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp2952829pxb; Mon, 16 Nov 2020 01:30:39 -0800 (PST) X-Google-Smtp-Source: ABdhPJws7l/GCBzAXIHyJCNpsie8bSEN6Z5ZsOcezL7O60Xm6m1AVmCkurCoJCe2Q+mFcc0kGasc X-Received: by 2002:a17:906:3c55:: with SMTP id i21mr1251872ejg.347.1605519039374; Mon, 16 Nov 2020 01:30:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605519039; cv=none; d=google.com; s=arc-20160816; b=An7XmTPTJ39ZQcF4GaTVv+/F46+Zlg9QxobNfgpVACcX6kH/jas1jHq7XUX49nBHsl C+TCgCi9Sa+V2np56dqhiVzlwFGHfqjzOUCne7yLfNZyRhiDTL+RiWyfUqZPtuB795hg L8GJ+oZyo0eMJRiDi4PPIy7iPUv4kOq9C34KdjoDZlaISbletaQuTSij+aZO6MAZ2KoW MUd6GKBYgPbdB/kgp+Mh07BBNEeGIBhBf3LBIiRp+QVi2b78/xTSwCILHHtd5PDXfbaO Mm/HcD/648zE8YfnzaWmyaqG7oKlLM9yOHVxm1gZaz7vN4LK3igFwNHwtXwB9BYqhIgA DT2Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=skkC23xhtkGvcAMDhu8nEf/QREzXYKt4XXEuAzIUoiY=; b=D4XarZ3dgcgE5oHcHsBChsyeBJcFvtvKUiUQIZzWMIcy8iZc4slwC5l102fzjGW4DV L4Vc7/cA09ougv4XtYEnmo9gLX87uVlbAavlv9ZgI1ivkwZBDsAPZMl7xeGs7ecucloz cPPNSxWVv8tqFUBIupCw7nleJNFbZGT4PUUL/BnzLl9usDd+qIJUmc4EM/0lp3ww/uFK tEhenhd8dvlle/FA5/A5Qz4eB8TFN+auwyfZ9XbISpqjd6mhvNGmzV0zien3W9c0He0n +a0NML/EJtgMU13p2LpcYmKzfulZ1mKkNieweNI4YWxBO6mCFbtC4CvrZo9dSTSUa11Z NFaQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i10si80888edj.558.2020.11.16.01.30.16; Mon, 16 Nov 2020 01:30:39 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728317AbgKPJ03 (ORCPT + 99 others); Mon, 16 Nov 2020 04:26:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53914 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726635AbgKPJ03 (ORCPT ); Mon, 16 Nov 2020 04:26:29 -0500 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CD134C0613CF for ; Mon, 16 Nov 2020 01:26:28 -0800 (PST) Received: from pty.hi.pengutronix.de ([2001:67c:670:100:1d::c5]) by metis.ext.pengutronix.de with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1keam2-0004FB-Dh; Mon, 16 Nov 2020 10:26:10 +0100 Received: from mfe by pty.hi.pengutronix.de with local (Exim 4.89) (envelope-from ) id 1kealz-0002Qj-L7; Mon, 16 Nov 2020 10:26:07 +0100 Date: Mon, 16 Nov 2020 10:26:07 +0100 From: Marco Felsch To: Florian Fainelli Cc: Jakub Kicinski , Zhang Changzhong , andrew@lunn.ch, hkallweit1@gmail.com, linux@armlinux.org.uk, davem@davemloft.net, 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() Message-ID: <20201116092607.psaelzuga3kcrryu@pengutronix.de> References: <1605180239-1792-1-git-send-email-zhangchangzhong@huawei.com> <20201114112625.440b52f2@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Sent-From: Pengutronix Hildesheim X-URL: http://www.pengutronix.de/ X-IRC: #ptxdist @freenode X-Accept-Language: de,en X-Accept-Content-Type: text/plain X-Uptime: 10:23:41 up 367 days, 42 min, 32 users, load average: 0.00, 0.05, 0.04 User-Agent: NeoMutt/20170113 (1.7.2) X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::c5 X-SA-Exim-Mail-From: mfe@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 20-11-14 11:45, Florian Fainelli wrote: > > > 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 > >> Signed-off-by: Zhang Changzhong > >> --- > >> 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. Hi, damn.. I missed the return here. Thanks for covering that. Should I send a fix or did you do that already? Regards, Marco