From: Vladimir Oltean <olteanv@gmail.com>
To: Hongling Zeng <zenghongling@kylinos.cn>
Cc: vkoul@kernel.org, neil.armstrong@linaro.org, johan@kernel.org,
kishon@kernel.org, linux-phy@lists.infradead.org,
linux-kernel@vger.kernel.org, zhongling0719@126.com
Subject: Re: [PATCH 1/2 v3] phy: ti: pipe3: Fix clock resource leak on probe errors
Date: Fri, 15 May 2026 18:55:58 +0300 [thread overview]
Message-ID: <20260515155558.eigeqtmkdifqciu5@skbuf> (raw)
In-Reply-To: <20260515040522.27793-1-zenghongling@kylinos.cn>
On Fri, May 15, 2026 at 12:05:22PM +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: move clk initialization to a separate function")
> Signed-off-by: Hongling Zeng <zenghongling@kylinos.cn>
>
Your patch numbering broke Patchwork. Please do not name patches 1/2 if
2/2 is not in the same thread. Neither this patch nor "[2/2] phy:
ti-pipe3: Fix EPROBE_DEFER handling for clock resources" can be applied.
Also, wasn't v3 this? https://patchwork.kernel.org/project/linux-phy/patch/20260515021635.13444-1-zenghongling@kylinos.cn/
shouldn't this be v4?
pw-bot: cr
> ---
> Change in v2:
> -Add pm_runtime_disable() in error path (reported by Sashiko AI).
> ---
> change in v3:
> -Fix unbalanced clock disable by checking clk_prepare_enable()return value and
> setting sata_refclk_enabledonly on success.
> -Fix error path teardown order to match ti_pipe3_remove()(disable clock before
> disabling runtime PM).
> ---
> drivers/phy/ti/phy-ti-pipe3.c | 26 ++++++++++++++++++++++----
> 1 file changed, 22 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/phy/ti/phy-ti-pipe3.c b/drivers/phy/ti/phy-ti-pipe3.c
> index b5543b5c674c..58fbc3b27813 100644
> --- a/drivers/phy/ti/phy-ti-pipe3.c
> +++ b/drivers/phy/ti/phy-ti-pipe3.c
> @@ -831,21 +831,39 @@ static int ti_pipe3_probe(struct platform_device *pdev)
> */
> if (phy->mode == PIPE3_MODE_SATA) {
> if (!IS_ERR(phy->refclk)) {
> - clk_prepare_enable(phy->refclk);
> + ret = clk_prepare_enable(phy->refclk);
> + if (ret) {
> + dev_err(dev, "Failed to enable refclk %d\n", ret);
> + goto err_pm_disable;
> + }
> phy->sata_refclk_enabled = true;
> }
> }
>
> 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 && !IS_ERR(phy->refclk))
> + clk_disable_unprepare(phy->refclk);
> +err_pm_disable:
> + pm_runtime_disable(dev);
> + 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
prev parent reply other threads:[~2026-05-15 15:56 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-15 4:05 [PATCH 1/2 v3] phy: ti: pipe3: Fix clock resource leak on probe errors Hongling Zeng
2026-05-15 15:55 ` Vladimir Oltean [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260515155558.eigeqtmkdifqciu5@skbuf \
--to=olteanv@gmail.com \
--cc=johan@kernel.org \
--cc=kishon@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-phy@lists.infradead.org \
--cc=neil.armstrong@linaro.org \
--cc=vkoul@kernel.org \
--cc=zenghongling@kylinos.cn \
--cc=zhongling0719@126.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox