diff mbox series

phy: phy-mtk-tphy: Fix some resource leaks in mtk_phy_init()

Message ID 1621257600-15046-1-git-send-email-yangtiezhu@loongson.cn (mailing list archive)
State New, archived
Headers show
Series phy: phy-mtk-tphy: Fix some resource leaks in mtk_phy_init() | expand

Commit Message

Tiezhu Yang May 17, 2021, 1:20 p.m. UTC
Use clk_disable_unprepare() in the error path of mtk_phy_init() to fix
some resource leaks.

Fixes: cd4ec4b03dc1 ("phy: phy-mt65xx-usb3: add mediatek directory and rename file")
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
---
 drivers/phy/mediatek/phy-mtk-tphy.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Chunfeng Yun (云春峰) May 19, 2021, 2:46 a.m. UTC | #1
On Mon, 2021-05-17 at 21:20 +0800, Tiezhu Yang wrote:
> Use clk_disable_unprepare() in the error path of mtk_phy_init() to fix
> some resource leaks.
> 
> Fixes: cd4ec4b03dc1 ("phy: phy-mt65xx-usb3: add mediatek directory and rename file")
No need add Fixes tag, there is no da_ref_clk when apply this patch,

> Reported-by: kernel test robot <lkp@intel.com>
> Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
> Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
> ---
>  drivers/phy/mediatek/phy-mtk-tphy.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/phy/mediatek/phy-mtk-tphy.c b/drivers/phy/mediatek/phy-mtk-tphy.c
> index cdbcc49..731c483 100644
> --- a/drivers/phy/mediatek/phy-mtk-tphy.c
> +++ b/drivers/phy/mediatek/phy-mtk-tphy.c
> @@ -949,6 +949,8 @@ static int mtk_phy_init(struct phy *phy)
>  		break;
>  	default:
>  		dev_err(tphy->dev, "incompatible PHY type\n");
> +		clk_disable_unprepare(instance->ref_clk);
> +		clk_disable_unprepare(instance->da_ref_clk);
>  		return -EINVAL;
>  	}
>  
after removing Fixes tag, 
Reviewed-by: Chunfeng Yun <chunfeng.yun@mediatek.com>

Thanks
diff mbox series

Patch

diff --git a/drivers/phy/mediatek/phy-mtk-tphy.c b/drivers/phy/mediatek/phy-mtk-tphy.c
index cdbcc49..731c483 100644
--- a/drivers/phy/mediatek/phy-mtk-tphy.c
+++ b/drivers/phy/mediatek/phy-mtk-tphy.c
@@ -949,6 +949,8 @@  static int mtk_phy_init(struct phy *phy)
 		break;
 	default:
 		dev_err(tphy->dev, "incompatible PHY type\n");
+		clk_disable_unprepare(instance->ref_clk);
+		clk_disable_unprepare(instance->da_ref_clk);
 		return -EINVAL;
 	}