From nobody Fri Jun 12 12:48:49 2026 Received: from mailgw.kylinos.cn (mailgw.kylinos.cn [124.126.103.232]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 717322765D4 for ; Fri, 15 May 2026 02:16:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=124.126.103.232 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778811411; cv=none; b=MT1LWbJR24Qw8yR9nkSnNEJ3Z/uLsTxLtWZRJTDYCrmFd5yXHwYopW9h/srJSKn/endSTLGBU2PJ6exzs2wqE6NHvEEC4wZy0prahSS0QnztVVBpkfCNyP8HHSwFuEZRmkxfz+fSHuLhaG3+V85droM7+Q/NMeHh36JgMRNAbok= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778811411; c=relaxed/simple; bh=01vJ3XQwIcJDmhlZbSBVX8Nl6lscTf7+kTsiMauVD4w=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=jJ5Hkfpbk6jPKwpyl/Tri8oglL8abgtCq3Id7X4zocCCXZOYwNgwQjjnO/Uv0JVir5CzpTu2SkEWTmwg8MBVfqUc4QypWLoINdk86UREIOjypjiuIY0MgdBRf4IZc5y+xD1hrF4ql7Z3+OtAs+Oi5FgasHfiRyY6PSa8Q5Q3Y9o= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kylinos.cn; spf=pass smtp.mailfrom=kylinos.cn; arc=none smtp.client-ip=124.126.103.232 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kylinos.cn Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=kylinos.cn X-UUID: 1c03cba0500411f1aa26b74ffac11d73-20260515 X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.3.12,REQID:8d5593fe-c09e-4e5a-8bf4-4dbb58e0acd0,IP:0,U RL:0,TC:0,Content:0,EDM:0,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTION: release,TS:0 X-CID-META: VersionHash:e7bac3a,CLOUDID:f33d0668e951b14355c86339346f9cac,BulkI D:nil,BulkQuantity:0,Recheck:0,SF:102|850|898,TC:nil,Content:0|15|50,EDM:- 3,IP:nil,URL:0,File:nil,RT:nil,Bulk:nil,QS:nil,BEC:nil,COL:0,OSI:0,OSA:0,A V:0,LES:1,SPR:NO,DKR:0,DKP:0,BRR:0,BRE:0,ARC:0 X-CID-BVR: 2,SSN|SDN X-CID-BAS: 2,SSN|SDN,0,_ X-CID-FACTOR: TF_CID_SPAM_SNR X-CID-RHF: D41D8CD98F00B204E9800998ECF8427E X-UUID: 1c03cba0500411f1aa26b74ffac11d73-20260515 X-User: zenghongling@kylinos.cn Received: from localhost.localdomain [(10.44.16.150)] by mailgw.kylinos.cn (envelope-from ) (Generic MTA with TLSv1.3 TLS_AES_256_GCM_SHA384 256/256) with ESMTP id 1176405023; Fri, 15 May 2026 10:16:40 +0800 From: Hongling Zeng To: vkoul@kernel.org, neil.armstrong@linaro.org, johan@kernel.org, kishon@kernel.org Cc: linux-phy@lists.infradead.org, linux-kernel@vger.kernel.org, zhongling0719@126.com, Hongling Zeng Subject: [PATCH v3] phy: ti: pipe3: Fix clock resource leak on probe errors Date: Fri, 15 May 2026 10:16:35 +0800 Message-Id: <20260515021635.13444-1-zenghongling@kylinos.cn> X-Mailer: git-send-email 2.25.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 --- 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 valu= e and setting sata_refclk_enabledonly on success. -Fix error path teardown order to match ti_pipe3_remove()(disable clock b= efore 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 *pde= v) */ if (phy->mode =3D=3D PIPE3_MODE_SATA) { if (!IS_ERR(phy->refclk)) { - clk_prepare_enable(phy->refclk); + ret =3D 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 =3D true; } } =20 generic_phy =3D devm_phy_create(dev, NULL, &ops); - if (IS_ERR(generic_phy)) - return PTR_ERR(generic_phy); + if (IS_ERR(generic_phy)) { + ret =3D PTR_ERR(generic_phy); + goto err_clk_disable; + } =20 phy_set_drvdata(generic_phy, phy); =20 ti_pipe3_power_off(generic_phy); =20 phy_provider =3D devm_of_phy_provider_register(dev, of_phy_simple_xlate); - return PTR_ERR_OR_ZERO(phy_provider); + if (IS_ERR(phy_provider)) { + ret =3D 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; } =20 static void ti_pipe3_remove(struct platform_device *pdev) --=20 2.25.1