* [PATCH] phy: ti: pipe3: Fix clock resource leak on probe errors
@ 2026-05-13 6:39 Hongling Zeng
2026-05-13 9:21 ` Vladimir Oltean
2026-05-14 2:10 ` sashiko-bot
0 siblings, 2 replies; 3+ messages in thread
From: Hongling Zeng @ 2026-05-13 6:39 UTC (permalink / raw)
To: vkoul, neil.armstrong, johan, kishon
Cc: linux-phy, linux-kernel, zhongling0719, Hongling Zeng
When devm_phy_create() or devm_of_phy_provider_register() fails,
the refclk that was enabled earlier is not disabled, causing a
resource leak.
Fix this by adding an error handling path to disable the clock
when these functions fail.
Fixes: 234738ea3390 ("phy: ti-pipe3: Add PHY driver for TI PIPE3 PHY")
Signed-off-by: Hongling Zeng <zenghongling@kylinos.cn>
---
drivers/phy/ti/phy-ti-pipe3.c | 18 +++++++++++++++---
1 file changed, 15 insertions(+), 3 deletions(-)
diff --git a/drivers/phy/ti/phy-ti-pipe3.c b/drivers/phy/ti/phy-ti-pipe3.c
index b5543b5c674c..29a4cbe73781 100644
--- a/drivers/phy/ti/phy-ti-pipe3.c
+++ b/drivers/phy/ti/phy-ti-pipe3.c
@@ -837,15 +837,27 @@ static int ti_pipe3_probe(struct platform_device *pdev)
}
generic_phy = devm_phy_create(dev, NULL, &ops);
- if (IS_ERR(generic_phy))
- return PTR_ERR(generic_phy);
+ if (IS_ERR(generic_phy)) {
+ ret = PTR_ERR(generic_phy);
+ goto err_clk_disable;
+ }
phy_set_drvdata(generic_phy, phy);
ti_pipe3_power_off(generic_phy);
phy_provider = devm_of_phy_provider_register(dev, of_phy_simple_xlate);
- return PTR_ERR_OR_ZERO(phy_provider);
+ if (IS_ERR(phy_provider)) {
+ ret = PTR_ERR(phy_provider);
+ goto err_clk_disable;
+ }
+
+ return 0;
+
+err_clk_disable:
+ if (phy->sata_refclk_enabled)
+ clk_disable_unprepare(phy->refclk);
+ return ret;
}
static void ti_pipe3_remove(struct platform_device *pdev)
--
2.25.1
--
linux-phy mailing list
linux-phy@lists.infradead.org
https://lists.infradead.org/mailman/listinfo/linux-phy
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] phy: ti: pipe3: Fix clock resource leak on probe errors
2026-05-13 6:39 [PATCH] phy: ti: pipe3: Fix clock resource leak on probe errors Hongling Zeng
@ 2026-05-13 9:21 ` Vladimir Oltean
2026-05-14 2:10 ` sashiko-bot
1 sibling, 0 replies; 3+ messages in thread
From: Vladimir Oltean @ 2026-05-13 9:21 UTC (permalink / raw)
To: Hongling Zeng
Cc: vkoul, neil.armstrong, johan, kishon, linux-phy, linux-kernel,
zhongling0719
On Wed, May 13, 2026 at 02:39:02PM +0800, Hongling Zeng wrote:
> When devm_phy_create() or devm_of_phy_provider_register() fails,
> the refclk that was enabled earlier is not disabled, causing a
> resource leak.
>
> Fix this by adding an error handling path to disable the clock
> when these functions fail.
>
> Fixes: 234738ea3390 ("phy: ti-pipe3: Add PHY driver for TI PIPE3 PHY")
> Signed-off-by: Hongling Zeng <zenghongling@kylinos.cn>
> ---
Fixes tag: Fixes: 234738ea3390 ("phy: ti-pipe3: Add PHY driver for TI PIPE3 PHY")
Has these problem(s):
- Subject does not match target commit subject
Just use
git log -1 --format='Fixes: %h ("%s")'
--
linux-phy mailing list
linux-phy@lists.infradead.org
https://lists.infradead.org/mailman/listinfo/linux-phy
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] phy: ti: pipe3: Fix clock resource leak on probe errors
2026-05-13 6:39 [PATCH] phy: ti: pipe3: Fix clock resource leak on probe errors Hongling Zeng
2026-05-13 9:21 ` Vladimir Oltean
@ 2026-05-14 2:10 ` sashiko-bot
1 sibling, 0 replies; 3+ messages in thread
From: sashiko-bot @ 2026-05-14 2:10 UTC (permalink / raw)
To: Hongling Zeng; +Cc: linux-phy, vkoul, neil.armstrong, olteanv
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Missing pm_runtime_disable() in the probe error path leaves PM runtime state unbalanced.
--
commit fd04e6bd036402bf170a7ff7978b95f1478bfd7b
Author: Hongling Zeng <zenghongling@kylinos.cn>
phy: ti: pipe3: Fix clock resource leak on probe errors
This commit addresses a clock resource leak in the probe error path of the
TI PIPE3 PHY driver. It adds an err_clk_disable label to ensure the reference
clock is disabled if PHY creation or provider registration fails.
> diff --git a/drivers/phy/ti/phy-ti-pipe3.c b/drivers/phy/ti/phy-ti-pipe3.c
> index b5543b5c674c8..29a4cbe737812 100644
> --- a/drivers/phy/ti/phy-ti-pipe3.c
> +++ b/drivers/phy/ti/phy-ti-pipe3.c
> @@ -837,15 +837,27 @@ static int ti_pipe3_probe(struct platform_device *pdev)
[ ... ]
> phy_provider = devm_of_phy_provider_register(dev, of_phy_simple_xlate);
> - return PTR_ERR_OR_ZERO(phy_provider);
> + if (IS_ERR(phy_provider)) {
> + ret = PTR_ERR(phy_provider);
> + goto err_clk_disable;
> + }
> +
> + return 0;
> +
> +err_clk_disable:
> + if (phy->sata_refclk_enabled)
> + clk_disable_unprepare(phy->refclk);
> + return ret;
Does this new error path leave the power management runtime state unbalanced?
Earlier in ti_pipe3_probe(), pm_runtime_enable(dev) is called. Without a
corresponding pm_runtime_disable() call in this error path, it looks like
the device's power management runtime state is left unbalanced, which can
trigger a warning on subsequent probe retries.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260513063902.113956-1-zenghongling@kylinos.cn?part=1
--
linux-phy mailing list
linux-phy@lists.infradead.org
https://lists.infradead.org/mailman/listinfo/linux-phy
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-05-14 2:10 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-13 6:39 [PATCH] phy: ti: pipe3: Fix clock resource leak on probe errors Hongling Zeng
2026-05-13 9:21 ` Vladimir Oltean
2026-05-14 2:10 ` sashiko-bot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox