Linux-PHY Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Wentao Liang <vulab@iscas.ac.cn>
To: alcooperx@gmail.com
Cc: bcm-kernel-feedback-list@broadcom.com, justin.chen@broadcom.com,
	kishon@kernel.org, linux-kernel@vger.kernel.org,
	linux-phy@lists.infradead.org, neil.armstrong@linaro.org,
	vkoul@kernel.org, Wentao Liang <vulab@iscas.ac.cn>,
	stable@vger.kernel.org
Subject: [PATCH] phy: usb: Fix USB 3.0 clock reference leak in brcm_usb_phy_dvr_init()
Date: Thu, 17 Sep 2026 13:36:51 +0000	[thread overview]
Message-ID: <20260917133651.2153617-1-vulab@iscas.ac.cn> (raw)

brcm_usb_phy_dvr_init() obtains usb_30_clk with of_clk_get_by_name(),
which takes a reference on the clock, but returns without calling
clk_put() when clk_prepare_enable() fails, when the suspend clock
request is deferred, or when devm_request_irq() fails.  The clock is
only handed to the driver on the success path, so nothing releases the
reference on these paths.

Drop it from the err_put_clks label, and clear usb_30_clk on the
-EPROBE_DEFER path where it holds an error pointer rather than a
reference.

Fixes: 49859e55e364 ("phy: usb: phy-brcm-usb: Add Broadcom STB USB phy driver")
Cc: stable@vger.kernel.org
Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
---
 drivers/phy/broadcom/phy-brcm-usb.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/phy/broadcom/phy-brcm-usb.c b/drivers/phy/broadcom/phy-brcm-usb.c
index 8ef8aa025789..d411512b1036 100644
--- a/drivers/phy/broadcom/phy-brcm-usb.c
+++ b/drivers/phy/broadcom/phy-brcm-usb.c
@@ -443,6 +443,7 @@ static int brcm_usb_phy_dvr_init(struct platform_device *pdev,
 		priv->usb_30_clk = of_clk_get_by_name(dn, "sw_usb3");
 		if (IS_ERR(priv->usb_30_clk)) {
 			if (PTR_ERR(priv->usb_30_clk) == -EPROBE_DEFER) {
+				priv->usb_30_clk = NULL;
 				err = -EPROBE_DEFER;
 				goto err_put_clks;
 			}
@@ -483,6 +484,7 @@ static int brcm_usb_phy_dvr_init(struct platform_device *pdev,
 	return 0;
 
 err_put_clks:
+	clk_put(priv->usb_30_clk);
 	clk_put(priv->usb_20_clk);
 	return err;
 }
-- 
2.34.1


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

                 reply	other threads:[~2026-09-17 13:36 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20260917133651.2153617-1-vulab@iscas.ac.cn \
    --to=vulab@iscas.ac.cn \
    --cc=alcooperx@gmail.com \
    --cc=bcm-kernel-feedback-list@broadcom.com \
    --cc=justin.chen@broadcom.com \
    --cc=kishon@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-phy@lists.infradead.org \
    --cc=neil.armstrong@linaro.org \
    --cc=stable@vger.kernel.org \
    --cc=vkoul@kernel.org \
    /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