Linux kernel -stable discussions
 help / color / mirror / Atom feed
* [PATCH v8 4/4] phy: ti-pipe3: Fix clock leaks in init/exit error paths
       [not found] <20260909122630.1313205-1-zenghongling@kylinos.cn>
@ 2026-09-09 12:26 ` Hongling Zeng
  2026-10-12 13:05   ` Manivannan Sadhasivam
  0 siblings, 1 reply; 2+ messages in thread
From: Hongling Zeng @ 2026-09-09 12:26 UTC (permalink / raw)
  To: vkoul, neil.armstrong, johan, kishon, rogerq
  Cc: linux-phy, linux-kernel, zhongling0719, Hongling Zeng, stable,
	Sashiko AI

Two paths return without disabling the clocks that ti_pipe3_init()
has just enabled, leaking clock enable references:

1. In ti_pipe3_init(), when regmap_update_bits() fails for PCIe mode,
   the function returns the error without calling
   ti_pipe3_disable_clocks(). The clocks stay permanently enabled
   since the PHY framework won't invoke the .exit callback on init
   failure.

2. In ti_pipe3_exit(), when the PHY is in SATA mode without
   dpll_reset_syscon, the function returns 0 early to avoid powering
   down the SATA DPLL (Errata i783), which also skips the
   ti_pipe3_disable_clocks() at the end of the function. Every
   init/exit cycle therefore leaks the clock enable reference taken
   in ti_pipe3_init().

Fix both by adding the missing ti_pipe3_disable_clocks() calls,
consistent with how the DPLL program error path handles cleanup.

Fixes: 234738ea3390 ("phy: ti-pipe3: move clk initialization to a separate function")
Fixes: 0a0830feb2ad ("phy: ti-pipe3: fix suspend")
Cc: stable@vger.kernel.org
Reported-by: Sashiko AI <sashiko@kernel.org>
Closes: https://lore.kernel.org/all/20260518023657.41852C2BCB0@smtp.kernel.org/
Signed-off-by: Hongling Zeng <zenghongling@kylinos.cn>
---
Change in v8:
 - Expand commit message to document the SATA exit-path clock leak
   and add its own Fixes tag.

Change in v7:
 -Restore the original `return ret` in the SATA PLL-locked init path.
---
 drivers/phy/ti/phy-ti-pipe3.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/phy/ti/phy-ti-pipe3.c b/drivers/phy/ti/phy-ti-pipe3.c
index fdd81c935e5f..0d4a49a3f0c7 100644
--- a/drivers/phy/ti/phy-ti-pipe3.c
+++ b/drivers/phy/ti/phy-ti-pipe3.c
@@ -518,6 +518,8 @@ static int ti_pipe3_init(struct phy *x)
 		val = 0x96 << OMAP_CTRL_PCIE_PCS_DELAY_COUNT_SHIFT;
 		ret = regmap_update_bits(phy->pcs_syscon, phy->pcie_pcs_reg,
 					 PCIE_PCS_MASK, val);
+		if (ret)
+			ti_pipe3_disable_clocks(phy);
 		return ret;
 	}
 
@@ -555,8 +557,10 @@ static int ti_pipe3_exit(struct phy *x)
 	/* If dpll_reset_syscon is not present we wont power down SATA DPLL
 	 * due to Errata i783
 	 */
-	if (phy->mode == PIPE3_MODE_SATA && !phy->dpll_reset_syscon)
+	if (phy->mode == PIPE3_MODE_SATA && !phy->dpll_reset_syscon) {
+		ti_pipe3_disable_clocks(phy);
 		return 0;
+	}
 
 	/* PCIe doesn't have internal DPLL */
 	if (phy->mode != PIPE3_MODE_PCIE) {
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v8 4/4] phy: ti-pipe3: Fix clock leaks in init/exit error paths
  2026-09-09 12:26 ` [PATCH v8 4/4] phy: ti-pipe3: Fix clock leaks in init/exit error paths Hongling Zeng
@ 2026-10-12 13:05   ` Manivannan Sadhasivam
  0 siblings, 0 replies; 2+ messages in thread
From: Manivannan Sadhasivam @ 2026-10-12 13:05 UTC (permalink / raw)
  To: Hongling Zeng
  Cc: vkoul, neil.armstrong, johan, kishon, rogerq, linux-phy,
	linux-kernel, zhongling0719, stable

On Wed, Sep 09, 2026 at 08:26:30PM +0800, Hongling Zeng wrote:
> Two paths return without disabling the clocks that ti_pipe3_init()
> has just enabled, leaking clock enable references:
> 
> 1. In ti_pipe3_init(), when regmap_update_bits() fails for PCIe mode,
>    the function returns the error without calling
>    ti_pipe3_disable_clocks(). The clocks stay permanently enabled
>    since the PHY framework won't invoke the .exit callback on init
>    failure.
> 
> 2. In ti_pipe3_exit(), when the PHY is in SATA mode without
>    dpll_reset_syscon, the function returns 0 early to avoid powering
>    down the SATA DPLL (Errata i783), which also skips the
>    ti_pipe3_disable_clocks() at the end of the function. Every
>    init/exit cycle therefore leaks the clock enable reference taken
>    in ti_pipe3_init().
> 
> Fix both by adding the missing ti_pipe3_disable_clocks() calls,
> consistent with how the DPLL program error path handles cleanup.
> 
> Fixes: 234738ea3390 ("phy: ti-pipe3: move clk initialization to a separate function")
> Fixes: 0a0830feb2ad ("phy: ti-pipe3: fix suspend")
> Cc: stable@vger.kernel.org

This is not really a stable candidate...

> Reported-by: Sashiko AI <sashiko@kernel.org>
> Closes: https://lore.kernel.org/all/20260518023657.41852C2BCB0@smtp.kernel.org/
> Signed-off-by: Hongling Zeng <zenghongling@kylinos.cn>

Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@oss.qualcomm.com>

- Mani

-- 
மணிவண்ணன் சதாசிவம்

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-10-12 13:05 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20260909122630.1313205-1-zenghongling@kylinos.cn>
2026-09-09 12:26 ` [PATCH v8 4/4] phy: ti-pipe3: Fix clock leaks in init/exit error paths Hongling Zeng
2026-10-12 13:05   ` Manivannan Sadhasivam

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox