[PATCH] phy: amlogic: meson-axg-mipi-dphy: fix clock leak in probe error paths
From: Xiangwu Lai
Date: Tue Nov 17 2026 - 20:37:32 EST
The probe path enables the pclk clock with clk_prepare_enable() but
none of the error paths that follow (reset_control_deassert(),
devm_phy_create(), devm_of_phy_provider_register()) disable it again.
When one of them fails, the prepared and enabled clock is leaked.
Use devm_clk_get_enabled() to get the clock, so the clock is disabled
and its reference released automatically if probe fails after it or
the driver detaches.
Fixes: 76aefb221146 ("phy: amlogic: Add AXG MIPI D-PHY driver")
Signed-off-by: Xiangwu Lai <laixiangwu@xxxxxxxxxxxxxxxxxxxx>
---
drivers/phy/amlogic/phy-meson-axg-mipi-dphy.c | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/drivers/phy/amlogic/phy-meson-axg-mipi-dphy.c b/drivers/phy/amlogic/phy-meson-axg-mipi-dphy.c
index 5e2b7d93b..8a132b0e7 100644
--- a/drivers/phy/amlogic/phy-meson-axg-mipi-dphy.c
+++ b/drivers/phy/amlogic/phy-meson-axg-mipi-dphy.c
@@ -355,7 +355,7 @@ static int phy_meson_axg_mipi_dphy_probe(struct platform_device *pdev)
if (IS_ERR(priv->regmap))
return PTR_ERR(priv->regmap);
- priv->clk = devm_clk_get(dev, "pclk");
+ priv->clk = devm_clk_get_enabled(dev, "pclk");
if (IS_ERR(priv->clk))
return PTR_ERR(priv->clk);
@@ -367,10 +367,6 @@ static int phy_meson_axg_mipi_dphy_probe(struct platform_device *pdev)
if (IS_ERR(priv->analog))
return PTR_ERR(priv->analog);
- ret = clk_prepare_enable(priv->clk);
- if (ret)
- return ret;
-
ret = reset_control_deassert(priv->reset);
if (ret)
return ret;
--
2.50.1.windows.1