]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
phy: zynqmp: fix clock error handling in xpsgtr_phy_init()
authorRadhey Shyam Pandey <radhey.shyam.pandey@amd.com>
Mon, 20 Jul 2026 15:38:30 +0000 (21:08 +0530)
committerVinod Koul <vkoul@kernel.org>
Wed, 22 Jul 2026 08:22:28 +0000 (13:52 +0530)
Propagate clk_prepare_enable() failures to the caller instead of
returning success, and disable the reference clock on initialization
error paths to avoid leaking clock references when phy_exit() is not
called.

Fixes: 25d700833513 ("phy: xilinx: phy-zynqmp: dynamic clock support for power-save")
Signed-off-by: Radhey Shyam Pandey <radhey.shyam.pandey@amd.com>
Reviewed-by: Michal Simek <michal.simek@amd.com>
Link: https://patch.msgid.link/20260720153832.1130006-2-radhey.shyam.pandey@amd.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
drivers/phy/xilinx/phy-zynqmp.c

index fe6b4925d1662197988f23d4cafbaa882af5185d..c8230f2bda6290910bd934d84912b7309c1505ad 100644 (file)
@@ -658,12 +658,13 @@ static int xpsgtr_phy_init(struct phy *phy)
 {
        struct xpsgtr_phy *gtr_phy = phy_get_drvdata(phy);
        struct xpsgtr_dev *gtr_dev = gtr_phy->dev;
-       int ret = 0;
+       int ret;
 
        mutex_lock(&gtr_dev->gtr_mutex);
 
        /* Configure and enable the clock when peripheral phy_init call */
-       if (clk_prepare_enable(gtr_dev->clk[gtr_phy->refclk]))
+       ret = clk_prepare_enable(gtr_dev->clk[gtr_phy->refclk]);
+       if (ret)
                goto out;
 
        /* Skip initialization if not required. */
@@ -673,7 +674,7 @@ static int xpsgtr_phy_init(struct phy *phy)
        if (gtr_dev->tx_term_fix) {
                ret = xpsgtr_phy_tx_term_fix(gtr_phy);
                if (ret < 0)
-                       goto out;
+                       goto out_disable_clk;
 
                gtr_dev->tx_term_fix = false;
        }
@@ -687,7 +688,7 @@ static int xpsgtr_phy_init(struct phy *phy)
         */
        ret = xpsgtr_configure_pll(gtr_phy);
        if (ret)
-               goto out;
+               goto out_disable_clk;
 
        xpsgtr_lane_set_protocol(gtr_phy);
 
@@ -705,6 +706,10 @@ static int xpsgtr_phy_init(struct phy *phy)
                break;
        }
 
+       goto out;
+
+out_disable_clk:
+       clk_disable_unprepare(gtr_dev->clk[gtr_phy->refclk]);
 out:
        mutex_unlock(&gtr_dev->gtr_mutex);
        return ret;