Linux-PHY Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Hongling Zeng" <zenghongling@kylinos.cn>
Cc: olteanv@gmail.com, linux-phy@lists.infradead.org,
	vkoul@kernel.org, neil.armstrong@linaro.org
Subject: Re: [PATCH v7 1/4] phy: ti-pipe3: Fix ignored clock enable return value  in init
Date: Wed, 09 Sep 2026 11:46:19 +0000	[thread overview]
Message-ID: <20260909114619.80A501F00A3D@smtp.kernel.org> (raw)
In-Reply-To: <20260909113433.1287454-2-zenghongling@kylinos.cn>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [High] Clock enable count leak on race condition error path during SATA lock check in ti_pipe3_init()
--

commit 6767d03245555c6eb67e9613e47d287d39988b18
Author: Hongling Zeng <zenghongling@kylinos.cn>

phy: ti-pipe3: Fix ignored clock enable return value in init

ti_pipe3_init() ignores the return value of ti_pipe3_enable_clocks(),
which can lead to unclocked hardware access and unbalanced clock disables.
Fix this by checking the return value and returning early if it fails.

> diff --git a/drivers/phy/ti/phy-ti-pipe3.c b/drivers/phy/ti/phy-ti-pipe3.c
> index b5543b5c674c8..0e3bc92187338 100644
> --- a/drivers/phy/ti/phy-ti-pipe3.c
> +++ b/drivers/phy/ti/phy-ti-pipe3.c
> @@ -498,9 +498,12 @@ static int ti_pipe3_init(struct phy *x)
>  {
>  	struct ti_pipe3 *phy = phy_get_drvdata(x);
>  	u32 val;
> -	int ret = 0;
> +	int ret;
> +
> +	ret = ti_pipe3_enable_clocks(phy);
> +	if (ret)
> +		return ret;
>  
> -	ti_pipe3_enable_clocks(phy);
>  	/*
>  	 * Set pcie_pcs register to 0x96 for proper functioning of phy

[Severity: High]
This is a pre-existing issue, but further down in this function, does this
leak the clock enable count on a race condition error path?

If ti_pipe3_dpll_wait_lock() fails due to a timeout (returning -EBUSY), but
the DPLL locks immediately after, (val & PLL_LOCK) will evaluate to true.

For SATA mode, it then returns the stale -EBUSY error without disabling the
clocks:

drivers/phy/ti/phy-ti-pipe3.c:ti_pipe3_init() {
    ...
	if (val & PLL_IDLE) {
		val &= ~PLL_IDLE;
		ti_pipe3_writel(phy->pll_ctrl_base, PLL_CONFIGURATION2, val);
		ret = ti_pipe3_dpll_wait_lock(phy);
	}

	/* SATA has issues if re-programmed when locked */
	val = ti_pipe3_readl(phy->pll_ctrl_base, PLL_STATUS);
	if ((val & PLL_LOCK) && phy->mode == PIPE3_MODE_SATA)
		return ret;
    ...
}

While this requires specific hardware timings or delays (like high load or
preemption) allowing the timeout to expire just before the lock succeeds, it
remains a structural leak on this failure path.

Should this failure path also call ti_pipe3_disable_clocks() before returning
an error, similar to the other error paths in this function?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260909113433.1287454-1-zenghongling@kylinos.cn?part=1

-- 
linux-phy mailing list
linux-phy@lists.infradead.org
https://lists.infradead.org/mailman/listinfo/linux-phy

  reply	other threads:[~2026-09-09 11:46 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-09 11:34 [PATCH v7 0/4] phy: ti-pipe3: Fix clock resource handling issues Hongling Zeng
2026-09-09 11:34 ` [PATCH v7 1/4] phy: ti-pipe3: Fix ignored clock enable return value in init Hongling Zeng
2026-09-09 11:46   ` sashiko-bot [this message]
2026-09-09 11:34 ` [PATCH v7 2/4] phy: ti: pipe3: Fix clock resource leak on probe errors Hongling Zeng
2026-09-09 11:34 ` [PATCH v7 3/4] phy: ti-pipe3: Fix EPROBE_DEFER handling for clock resources Hongling Zeng
2026-09-09 11:42   ` sashiko-bot
2026-09-09 11:34 ` [PATCH v7 4/4] phy: ti-pipe3: Fix clock leak in init error path Hongling Zeng
2026-09-09 11:43   ` sashiko-bot

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=20260909114619.80A501F00A3D@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=linux-phy@lists.infradead.org \
    --cc=neil.armstrong@linaro.org \
    --cc=olteanv@gmail.com \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=vkoul@kernel.org \
    --cc=zenghongling@kylinos.cn \
    /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