mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] phy: nuvoton: Fix clock reference leak in ma35_usb_phy_probe()
@ 2026-09-17 13:43 Wentao Liang
  0 siblings, 0 replies; only message in thread
From: Wentao Liang @ 2026-09-17 13:43 UTC (permalink / raw)
  To: hpchen0nvt
  Cc: linux-arm-kernel, linux-kernel, linux-phy, neil.armstrong,
	schung, vkoul, ychuang3, Wentao Liang, stable

ma35_usb_phy_probe() obtains the USB PHY clock with of_clk_get(), but
returns without calling clk_put() when devm_phy_create() or
devm_of_phy_provider_register() fails, leaking the reference.  The
clock is only meant to be kept on the success path, where it is stored
in p_phy->clk and used by the PHY operations.

Drop the reference on those two error paths.

Fixes: b48baf69db97 ("phy: nuvoton: add new driver for the Nuvoton MA35 SoC USB 2.0 PHY")
Cc: stable@vger.kernel.org
Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
---
 drivers/phy/nuvoton/phy-ma35d1-usb2.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/drivers/phy/nuvoton/phy-ma35d1-usb2.c b/drivers/phy/nuvoton/phy-ma35d1-usb2.c
index 9a459b700ed4..3752e244134b 100644
--- a/drivers/phy/nuvoton/phy-ma35d1-usb2.c
+++ b/drivers/phy/nuvoton/phy-ma35d1-usb2.c
@@ -111,15 +111,20 @@ static int ma35_usb_phy_probe(struct platform_device *pdev)
 				     "failed to find usb_phy clock\n");
 
 	phy = devm_phy_create(&pdev->dev, NULL, &ma35_usb_phy_ops);
-	if (IS_ERR(phy))
-		return dev_err_probe(&pdev->dev, PTR_ERR(phy), "Failed to create PHY\n");
+	if (IS_ERR(phy)) {
+		clk_put(p_phy->clk);
+		return dev_err_probe(&pdev->dev, PTR_ERR(phy),
+				     "Failed to create PHY\n");
+	}
 
 	phy_set_drvdata(phy, p_phy);
 
 	provider = devm_of_phy_provider_register(&pdev->dev, of_phy_simple_xlate);
-	if (IS_ERR(provider))
+	if (IS_ERR(provider)) {
+		clk_put(p_phy->clk);
 		return dev_err_probe(&pdev->dev, PTR_ERR(provider),
 				     "Failed to register PHY provider\n");
+	}
 	return 0;
 }
 
-- 
2.34.1


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2026-09-17 13:43 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-17 13:43 [PATCH] phy: nuvoton: Fix clock reference leak in ma35_usb_phy_probe() Wentao Liang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®