Received: by 10.213.65.68 with SMTP id h4csp916815imn; Tue, 20 Mar 2018 20:05:27 -0700 (PDT) X-Google-Smtp-Source: AG47ELuf39o4jtcVlrsDkB8MxImeVZG+5Xlw8HQ0u/35RGAxhfljmEsKgv973tnSK+GDfM9KmPRc X-Received: by 10.98.214.91 with SMTP id r88mr6251018pfg.8.1521601527867; Tue, 20 Mar 2018 20:05:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521601527; cv=none; d=google.com; s=arc-20160816; b=NrJODCcTitBD7eF/2+W6dHdZhf5Z6xs3y1reYUbDuR9aRrsv7J8RYvCNKY+toiEG6Q cQLlMbwUGMyl220YIbyjI38uCizMXS5bU+w+JYZZgqxY+s4VNwYsydAEuHjA+KXFXpls ktr+PQ+nenI6xIxlZJ8Vartjs9aT0HEpSdd1QrL74XKh+GiOppiaFK6xVUs+kLo4BPVz 6kB9hDTJLpaD9fwTrl7Qj3EFV6zSMdQJCJzqeoS1fxscfNdMJZ9+VvQW1qOk/xhILFLY 7VosE3le0dUp7IQyMOqrK4PPy88vofNKhUgVJigtz51vUEVitWJCOz/b4wHPMGtpgqUJ VMyw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :references:in-reply-to:date:cc:to:from:subject:message-id :arc-authentication-results; bh=PXfhvdc/YpKu4hWJ+CWlOAJhVLRKQMPjK1zTpyDy2+Q=; b=EDUGcxnBYhVxFvLzEpQSKvxsV0n0iMEIR9Lj4rPjiPKSSb09yesx6C47GKjtnOEBQU fuYPTiC842bcdQJ5tUz2P2bpNMnfHmq8f4e4CQFfP2ZSFbu43aGUZ0qaQXKbkBP1C3Ia se1hJY+UitIbk9yAn7nIjZekAopfFH0WmOuEpyoQmBhViIuwhBhGDvDApXsC3qYKZipZ kxNR+M1L9qKcnkIBwQwlBT3U36sXLUobb+tXRygu146HtID7svPYI1eUSao6FUzjkJii izlMZbDhi26q4dIHaArZqJcEORCKKhsAZZoeaJaSS5E+xErCmZYwdtB+VuNFnt6vkE+Z u+zw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r30si2108369pgu.587.2018.03.20.20.05.13; Tue, 20 Mar 2018 20:05:27 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751786AbeCUDEV (ORCPT + 99 others); Tue, 20 Mar 2018 23:04:21 -0400 Received: from Mailgw01.mediatek.com ([1.203.163.78]:8464 "EHLO mailgw01.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1751531AbeCUDEU (ORCPT ); Tue, 20 Mar 2018 23:04:20 -0400 X-UUID: 3bd3df6c9a924b668f10efc313b38da6-20180321 Received: from mtkcas36.mediatek.inc [(172.27.4.250)] by mailgw01.mediatek.com (envelope-from ) (mailgw01.mediatek.com ESMTP with TLS) with ESMTP id 563232831; Wed, 21 Mar 2018 11:04:15 +0800 Received: from MTKCAS36.mediatek.inc (172.27.4.186) by MTKMBS31N1.mediatek.inc (172.27.4.69) with Microsoft SMTP Server (TLS) id 15.0.1210.3; Wed, 21 Mar 2018 11:04:14 +0800 Received: from [10.17.3.153] (10.17.3.153) by MTKCAS36.mediatek.inc (172.27.4.170) with Microsoft SMTP Server id 15.0.1210.3 via Frontend Transport; Wed, 21 Mar 2018 11:04:13 +0800 Message-ID: <1521601453.3717.117.camel@mhfsdcap03> Subject: Re: [PATCH -next] phy: phy-mtk-tphy: fix missing clk_disable_unprepare() on error in mtk_phy_init() From: Chunfeng Yun To: Wei Yongjun CC: Kishon Vijay Abraham I , Matthias Brugger , , , , Date: Wed, 21 Mar 2018 11:04:13 +0800 In-Reply-To: <1521551999-154546-1-git-send-email-weiyongjun1@huawei.com> References: <1521551999-154546-1-git-send-email-weiyongjun1@huawei.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.2.3-0ubuntu6 Content-Transfer-Encoding: 7bit MIME-Version: 1.0 X-MTK: N Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 2018-03-20 at 13:19 +0000, Wei Yongjun wrote: > Fix the missing clk_disable_unprepare() before return > from mtk_phy_init() in the error handling case. > > Signed-off-by: Wei Yongjun > --- > drivers/phy/mediatek/phy-mtk-tphy.c | 11 +++++++++-- > 1 file changed, 9 insertions(+), 2 deletions(-) > > diff --git a/drivers/phy/mediatek/phy-mtk-tphy.c b/drivers/phy/mediatek/phy-mtk-tphy.c > index 38c281b..3ff9020 100644 > --- a/drivers/phy/mediatek/phy-mtk-tphy.c > +++ b/drivers/phy/mediatek/phy-mtk-tphy.c > @@ -841,7 +841,7 @@ static int mtk_phy_init(struct phy *phy) > ret = clk_prepare_enable(instance->ref_clk); > if (ret) { > dev_err(tphy->dev, "failed to enable ref_clk\n"); > - return ret; > + goto disable_u3phya_ref; @u3phya_ref and @ref_clk clocks are mutually exclusive, that means one of them must be NULL; so if failed to enable @ref_clk, then @u3phya_ref should be NULL, and no need to disable it in fact. But it's also no problem to disable it. > } > > switch (instance->type) { > @@ -859,10 +859,17 @@ static int mtk_phy_init(struct phy *phy) > break; > default: > dev_err(tphy->dev, "incompatible PHY type\n"); > - return -EINVAL; > + ret = -EINVAL; > + goto disable_ref_clk; mtk_phy_xlate() has already checked supported type,so usually doesn't comes here, otherwise there will be a serious problem about system. Anyway, it's better to disable these clocks when fail. > } > > return 0; > + > +disable_ref_clk: > + clk_disable_unprepare(instance->ref_clk); > +disable_u3phya_ref: > + clk_disable_unprepare(tphy->u3phya_ref); > + return ret; > } > > static int mtk_phy_power_on(struct phy *phy) > Tested-by: Chunfeng Yun Acked-by: Chunfeng Yun Thanks a lot > >