public inbox for linux-arm-kernel@lists.infradead.org 
 help / color / mirror / Atom feed
From: Felix Gu <ustc.gu@gmail•com>
To: Vinod Koul <vkoul@kernel•org>,
	 Neil Armstrong <neil.armstrong@linaro•org>,
	Frank Li <Frank.Li@nxp•com>,
	 Sascha Hauer <s.hauer@pengutronix•de>,
	 Pengutronix Kernel Team <kernel@pengutronix•de>,
	 Fabio Estevam <festevam@gmail•com>, Xu Yang <xu.yang_2@nxp•com>
Cc: linux-phy@lists•infradead.org, imx@lists•linux.dev,
	 linux-arm-kernel@lists•infradead.org,
	linux-kernel@vger•kernel.org,  Felix Gu <ustc.gu@gmail•com>
Subject: [PATCH] phy: fsl-imx8mq-usb: fix vbus regulator leak on error paths
Date: Tue, 02 Jun 2026 21:14:33 +0800	[thread overview]
Message-ID: <20260602-imx9mq-v1-1-e58b912923d2@gmail.com> (raw)

In imx8mq_phy_power_on(), if clk_prepare_enable() fails after
regulator_enable() has succeeded, the vbus regulator is left
enabled. The same issue exists for the alt_clk error path.

Fix both by converting to the standard goto-based cleanup
pattern, ensuring the regulator is disabled when any
subsequent step fails.

Fixes: 3b64ea4768e7 ("phy: fsl-imx8mq-usb: support alternate reference clock")
Signed-off-by: Felix Gu <ustc.gu@gmail•com>
---
 drivers/phy/freescale/phy-fsl-imx8mq-usb.c | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/drivers/phy/freescale/phy-fsl-imx8mq-usb.c b/drivers/phy/freescale/phy-fsl-imx8mq-usb.c
index b05d80e849a1..e45e4f16057e 100644
--- a/drivers/phy/freescale/phy-fsl-imx8mq-usb.c
+++ b/drivers/phy/freescale/phy-fsl-imx8mq-usb.c
@@ -627,13 +627,11 @@ static int imx8mq_phy_power_on(struct phy *phy)
 
 	ret = clk_prepare_enable(imx_phy->clk);
 	if (ret)
-		return ret;
+		goto disable_vbus;
 
 	ret = clk_prepare_enable(imx_phy->alt_clk);
-	if (ret) {
-		clk_disable_unprepare(imx_phy->clk);
-		return ret;
-	}
+	if (ret)
+		goto disable_clk;
 
 	/* Disable rx term override */
 	value = readl(imx_phy->base + PHY_CTRL6);
@@ -641,6 +639,13 @@ static int imx8mq_phy_power_on(struct phy *phy)
 	writel(value, imx_phy->base + PHY_CTRL6);
 
 	return 0;
+
+disable_clk:
+	clk_disable_unprepare(imx_phy->clk);
+disable_vbus:
+	regulator_disable(imx_phy->vbus);
+
+	return ret;
 }
 
 static int imx8mq_phy_power_off(struct phy *phy)

---
base-commit: 08484c504b55a98bd100527fbe10a3caf55ff3ff
change-id: 20260602-imx9mq-30169239b590

Best regards,
--  
Felix Gu <ustc.gu@gmail•com>



             reply	other threads:[~2026-06-02 13:14 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-02 13:14 Felix Gu [this message]
2026-06-02 13:22 ` [PATCH] phy: fsl-imx8mq-usb: fix vbus regulator leak on error paths Frank Li
2026-06-03  5:39 ` Xu Yang

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=20260602-imx9mq-v1-1-e58b912923d2@gmail.com \
    --to=ustc.gu@gmail$(echo .)com \
    --cc=Frank.Li@nxp$(echo .)com \
    --cc=festevam@gmail$(echo .)com \
    --cc=imx@lists$(echo .)linux.dev \
    --cc=kernel@pengutronix$(echo .)de \
    --cc=linux-arm-kernel@lists$(echo .)infradead.org \
    --cc=linux-kernel@vger$(echo .)kernel.org \
    --cc=linux-phy@lists$(echo .)infradead.org \
    --cc=neil.armstrong@linaro$(echo .)org \
    --cc=s.hauer@pengutronix$(echo .)de \
    --cc=vkoul@kernel$(echo .)org \
    --cc=xu.yang_2@nxp$(echo .)com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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