From nobody Mon Nov 23 10:33:12 2026 Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=100.103.45.18 ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1795412454; b=NUl+Q2eddPsSnUN/YQ6VAfHVConaF9Bap6rVV0ZydUPhq5E7tp6Wtn+rRjBtyKZCctiq Vgd3NLrhCOfkxwORpmWCHzdUmDJ4UNQqxKJ2r5ZFDhgtmynoFgGEJxZ6QZ7CSEeduP7vn Cv4rCUIhyU2SsbCWmRQV0VSjdbTIOrw5YNRr+I3rL1FHzUd68YOmUjQWCjaDQIX2FAJB+ ibCgx6sEYBtTq/z1oTQ6xR9CMuR2KVCQFTBFeuK9Xg7NRXcaqlU8BB6cKfs6OUykxqXVC Srm+WIjEx/hxbeqvmc1vcPJqjw8ysIZSbajKjPXDe3PwVjG2ODe2Oq2Gw6Pi5nMpUGg== ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795412454; h=Received:DKIM-Signature:Received:From:Date:Subject:MIME-Version: Content-Type:Content-Transfer-Encoding:Message-Id:References: In-Reply-To:To:Cc:X-Mailer:X-Developer-Signature:X-Developer-Key: X-Endpoint-Received:X-Original-From:Reply-To; bh=a2j5Kc1s676fW7eQHIYbK9OilEv/Eztd/nWn/wnKjFk=; b=N+6Ze287J6b9+Hr28j03Sqlqnz4UjN45qiX4VhhEO+OoYpIrHAiOCWDw/4vfYTPIWD0t JyTExvLGqF0s+lIEFyhr/p6RpbNieEh5lRxlVLGaeeTI9+sKj/uo2bji66MLpD4Bn1QQ8 j8RIHzPFUBMciLEeljuvAklZ1JdepOH7rEXj8Xk5J20q6Hx4K2cPSCf09/o/kMbLHjZfx AGdODdDPe/VmA++y6WkiGUBfn7ck44qjAInE/bVTU5FDF8FTDaydIkdaFhvyVO6h7pNC7 e/9PcjlLNqN7pFKT7Z0sVZfVXXMP+8uKtAi53I9bSjE9PdBa/km0/d3c7FFe5gMVDOQ== ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=GAMdw+h+; arc=pass header.oldest-pass=0 smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A5A16606A31A; Mon, 23 Nov 2026 05:40:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=GAMdw+h+ Authentication-Results: smtp.kernel.org; arc=none smtp.remote-ip=100.80.115.77 ARC-Seal: i=1; d=kernel.org; s=arc20260519; a=rsa-sha256; cv=none; t=1795412453; b=sRBU/HJaGTKqb6BKnOwNApUGQ1VmeCippmK8KCsTrhosnlPF8QgAWHlh7D0XUgJpCvUl K8D+Lmb+U21KHucytEuCVeJG3kb3NaPLvcE6G/9ogx5AhynfdxniJfIYZ5tOGMy0Q51gW eYYOu13m9YN+ZlFPG9z1Ac8MMjak/PytV6zxix6NOjthq5ZDJxdo1oLDwFeMH9p8WM9+P R/NSwjKYxqAKjnUKtPPY92O/3a39QE+1omT1yMkTPQVzgDh2zgYmvER4si36WJ+Z5pJZS wWcmYUh6GO6ceixHcrNiHbyIZVjGs4u9/qStyHfENANszH7neHfDCyDbpfzxfJgTIIQ== ARC-Message-Signature: i=1; d=kernel.org; s=arc20260519; a=rsa-sha256; c=relaxed/relaxed; t=1795412453; h=DKIM-Signature:Received:From:Date:Subject:MIME-Version:Content-Type: Content-Transfer-Encoding:Message-Id:References:In-Reply-To:To:Cc: X-Mailer:X-Developer-Signature:X-Developer-Key:X-Endpoint-Received: X-Original-From:Reply-To; bh=a2j5Kc1s676fW7eQHIYbK9OilEv/Eztd/nWn/wnKjFk=; b=so2wYJcciB4tvEo0ZaGpu8yvTcTQHxaW0Wl7VWx76o5uOSNb9AYHHvuXICsW1YkIGDB/ FWZIL/Dnv7DHhL8gyA8dj1TtFBd1mqJyulp6voYL/ATRR7tUZ9x0Pwe7MdBc7GtROatGl OhEqltpxWL1N/BZfZrM7PYHZU+rTlHypXceajEVAiNeZmu3V+06J7sHhdJn2dS8n9y6Zx kHLUhO5t2XaHE6kGqAk0YztymT64Sa4kvrnDENTf2Bn/IHS4q8eDVnymhtyWfLuHDj75O 5cmziPG3AQICSxKoMtd8+XFR6yI0uQCWIjIB46yTAhDCp45kzKvUleDs5tRVgBknouQ== ARC-Authentication-Results: i=1; smtp.kernel.org; arc=none smtp.remote-ip=100.80.115.77 Received: from lkml.kernel.org (nexus.subspace.kernel.org [100.80.115.77]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.kernel.org (Postfix) with ESMTPS id 426091F000CA; Mon, 23 Nov 2026 05:40:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795412453; bh=a2j5Kc1s676fW7eQHIYbK9OilEv/Eztd/nWn/wnKjFk=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To; b=GAMdw+h+vtcZNLNrk2ZMzMeszdGuf1KAoYz4kt5rHFuFXbIyLQ6vMz0l5puffaFCA 3zrJ6laN/UYQdruL8xw+zxMfpyRdkN66sXMxV74jvBhvAjSc9xlIrn4Rfh3c//BZiZ RJ1ewsITOCwQ1bMDO/I8FoSojmHq6LsSkxEhCWE37g7QMeckR8vbBQT+5Yq8HWlEyu qjNZoIENmtRnQenctPWvfVCq9+vXQiqb5+RHcwt+cLWZir5HE1UsUo7kPjs6ectQK+ kMmSv9wjItH4sNl4GtOznZUn89QqEaG5YmMiA7xyW6JqcZK57DLC8QlHpMi2hI4HgO HdAAnULdyQGvQ== Received: from nexus.subspace.kernel.org (localhost [IPv6:::1]) by lkml.kernel.org (Postfix) with ESMTP id B97474C375; Mon, 23 Nov 2026 05:40:44 +0000 (UTC) From: Suyuan Wang via B4 Relay Date: Mon, 23 Nov 2026 05:40:43 +0000 Subject: [PATCH v3 1/3] cpufreq: highbank: Put cpu clock if clk notifier registration fails X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261123-cpufreq-leaks-v3-1-1f1e3f4f5a7b@gmail.com> References: <20261123-cpufreq-leaks-v3-0-1f1e3f4f5a7b@gmail.com> In-Reply-To: <20261123-cpufreq-leaks-v3-0-1f1e3f4f5a7b@gmail.com> To: viresh.kumar@linaro.org, krzk@kernel.org, peter.griffin@linaro.org, rafael@kernel.org Cc: linux-kernel@vger.kernel.org, zhongqiu.han@oss.qualcomm.com, alim.akhtar@samsung.com, linux-pm@vger.kernel.org, linux-samsung-soc@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-Mailer: b4 0.15.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1795412443; l=1191; i=shyckless@gmail.com; s=default; h=from:subject:message-id; bh=3b4Eah/SbdO4jSb11UoHLDLuYNJ6Mq7k1WUlVwvCviI=; b=t4P3ROXI3zaDZqIU2Ozy1qW1ZVms83OLGUuyv9Fju6klg3pWwvZeBdc/wyUwwwhAXO86IrFS8 KXaAx2Gk3WfBowA4j2fBW5S6ygDWUrJaknqykAW4dFJYdrQ2hzLUjUG X-Developer-Key: i=shyckless@gmail.com; a=ed25519; pk=pMtccVGiWES3bV+7YBFuBclkvq2n2HBHQ5azaBrK2lY= X-Endpoint-Received: by B4 Relay for shyckless@gmail.com/default with auth_id=1498 X-Original-From: Suyuan Wang Reply-To: shyckless@gmail.com From: Suyuan Wang hb_cpufreq_driver_init() gets the cpu0 clock with clk_get() and then registers a clk notifier on it. If clk_notifier_register() fails, the function jumps to out_put_node and returns the error, but the clock reference is never dropped. Call clk_put() on that error path. Found with a static analysis tool and checked by hand. Fixes: 6754f556103b ("cpufreq / highbank: add support for highbank cpufreq") Reviewed-by: Zhongqiu Han Co-developed-by: Kaixuan Li Signed-off-by: Kaixuan Li Signed-off-by: Suyuan Wang --- drivers/cpufreq/highbank-cpufreq.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/cpufreq/highbank-cpufreq.c b/drivers/cpufreq/highbank-= cpufreq.c index a45864701143..ccdaff4384d2 100644 --- a/drivers/cpufreq/highbank-cpufreq.c +++ b/drivers/cpufreq/highbank-cpufreq.c @@ -89,6 +89,7 @@ static int __init hb_cpufreq_driver_init(void) ret =3D clk_notifier_register(cpu_clk, &hb_cpufreq_clk_nb); if (ret) { pr_err("failed to register clk notifier: %d\n", ret); + clk_put(cpu_clk); goto out_put_node; } =20 --=20 2.34.1 From nobody Mon Nov 23 10:33:12 2026 Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=100.103.45.18 ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1795412457; b=SbizrSpRGsIfrKfu6tjgGQp3fZ0D8Xxb8NS8WyobwpJezhibD+9YVUKgt+huYJ2UK87T tVcA16/qrj/a/teAseJlLoIV9sISeJOH7B3vqHrTp5EQ21yJsEIJ6lPr8ehbgR98BbIHK oK4oRdCv1VpSYAnc7cWEFHZkW8rT/fhthINI8BulEKBFszF92y5iw6n4ij1ebv9kTbzEH Cmdob2qCccZ9kbJ6fFFn7SD3CU5Bi0wnA1Uuu2N/I5HgLIWAqrO0QQpLd902AV0MSouDP 6Tq//BTt4a2cp+LaFGT4gGeyFVPVUzNmXw+/bsVp0ho0hYEJ2XO3HIIyxlQhUuAtLZg== ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795412457; h=Received:DKIM-Signature:Received:From:Date:Subject:MIME-Version: Content-Type:Content-Transfer-Encoding:Message-Id:References: In-Reply-To:To:Cc:X-Mailer:X-Developer-Signature:X-Developer-Key: X-Endpoint-Received:X-Original-From:Reply-To; bh=GVC+Yr2jWlQIqBMa9+vblOZChfYVIufKhRQj9+To+0I=; b=RKaTt5mBRit8lIT+HORsc4fhjPzr4I7ba9on7KPrsQCF1tK7kQYxFvNyp4EfvHPkPLM6 7oFkKR313WySFYurOiJphIISGqCTwaGDxfM3Z3sBJVNP898UBdYzkuFroUDP14TzIaFU0 h7P2Llhzc7x/Pj1x+vp/aVRbOt50SbE1zwexhb1T1IXM2Ot2kPwjZ7Yti11WRh9beRsmj aD9++SXIWXr97G3K72AP6Pa/ZSgoD+FeRSZvQ1TXfQVNP6Z3xyZMJQ9hsVRfvJqw10bJO LMuzat6jjJa5+3/Za+XosDH5NmS16rgTupz03n6Vf+cO6yQHMiAUpeJWajzFWhjAuyg== ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=OPis5Fn8; arc=pass header.oldest-pass=0 smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EBFB6606A681; Mon, 23 Nov 2026 05:40:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=OPis5Fn8 Authentication-Results: smtp.kernel.org; arc=none smtp.remote-ip=100.80.115.77 ARC-Seal: i=1; d=kernel.org; s=arc20260519; a=rsa-sha256; cv=none; t=1795412456; b=g+raZMaSjpPefXZnEBRlclBvPqLAdMcgrgi4yJSTOCW2WxRolnBWCJNFwlIw9RXF1lhW /bhB7NywqPgMu/bimeXbhBJbpf8+xuHN1a5vlzO1oj6yEqTMcdOljeuCkXRYfADMdOmrC 9Az83Ps5zsz+BFE0DCP0KOCfglw3B+g+xJ39OK1KMqtXNKJKeuMbzgLgjvIxNhZ0YKy+W n81G2Os+yuULiYgPgpItRtRzMwSmhyJ5IExyR/JChf9+J3yW52gnDmJbM4Kbc++8h/ZnD B8rfWmMtHx2wyp20FxD4zsbzHtifADOH/YdKl1pdaoVpUjbadkQn9aOPOYUelgxjP/w== ARC-Message-Signature: i=1; d=kernel.org; s=arc20260519; a=rsa-sha256; c=relaxed/relaxed; t=1795412456; h=DKIM-Signature:Received:From:Date:Subject:MIME-Version:Content-Type: Content-Transfer-Encoding:Message-Id:References:In-Reply-To:To:Cc: X-Mailer:X-Developer-Signature:X-Developer-Key:X-Endpoint-Received: X-Original-From:Reply-To; bh=GVC+Yr2jWlQIqBMa9+vblOZChfYVIufKhRQj9+To+0I=; b=F8CIMo+ahlPtC536qRG+nFpGMmqY3DUwTE+81w+X+ECTZ2nVvDT5gLqIpd+q6/Aw6lvh OpL3MpqLfgukDfrEsH4vRrCQctLzc82eEhsJfHaH/7aVsa7AXvNvYypJ3aabsIuq2UnLW 9wiE+7znI4SDmzJJtrpsRzyxqVF8O/dhpVTxGlgDI9fmPxsBaS5GHCVxiSMrubZrG3Egr EHiyv4X87t2NvAt/PVR2/GRjZDwZO/EDdA70gcK48BED3RUx5JS+/jjIvhpuBnfQLMaz+ kO6/kCZkKo2yTjzDc4iHvFP9S8D9Fk7SV/emTuuXtkH3NSevsu+INkayq5AiX7wiihQ== ARC-Authentication-Results: i=1; smtp.kernel.org; arc=none smtp.remote-ip=100.80.115.77 Received: from lkml.kernel.org (nexus.subspace.kernel.org [100.80.115.77]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.kernel.org (Postfix) with ESMTPS id 541B61F000CF; Mon, 23 Nov 2026 05:40:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795412456; bh=GVC+Yr2jWlQIqBMa9+vblOZChfYVIufKhRQj9+To+0I=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To; b=OPis5Fn8B3y86Xu5lY9D7IN7HlzU8JcbwPOcTjxvbQH9xE/AgTBVMEE1UnSTk1ASJ QCaV2iddglhcbNeflc/HzWMspUfeFHGgnJTHIs+wgmiiukGnaiFT87yFjulZ/U8cg/ q4KQdwCUdCiNiONDLUUY1bKdrofoREckQEiL5exNAyYwjmkS/vBlOWJtsES6C24lUt Kj59NUkDnciLo65pvfBNFulb29ZBYsnja44x2WpEC3uIee+EZ3d11MCrC2l0t2t1E2 NbwGNx0yeRJRZ6ghevI3QtwyXLsCkdsP/XNtwFwUy4yD2W6uLDHVkW3DzscEIayyDV J+iswaYFBPOcA== Received: from nexus.subspace.kernel.org (localhost [IPv6:::1]) by lkml.kernel.org (Postfix) with ESMTP id D4BA84C37A; Mon, 23 Nov 2026 05:40:44 +0000 (UTC) From: Suyuan Wang via B4 Relay Date: Mon, 23 Nov 2026 05:40:44 +0000 Subject: [PATCH v3 2/3] cpufreq: kirkwood: Put clocks on error and in remove X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261123-cpufreq-leaks-v3-2-1f1e3f4f5a7b@gmail.com> References: <20261123-cpufreq-leaks-v3-0-1f1e3f4f5a7b@gmail.com> In-Reply-To: <20261123-cpufreq-leaks-v3-0-1f1e3f4f5a7b@gmail.com> To: viresh.kumar@linaro.org, krzk@kernel.org, peter.griffin@linaro.org, rafael@kernel.org Cc: linux-kernel@vger.kernel.org, zhongqiu.han@oss.qualcomm.com, alim.akhtar@samsung.com, linux-pm@vger.kernel.org, linux-samsung-soc@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-Mailer: b4 0.15.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1795412443; l=3042; i=shyckless@gmail.com; s=default; h=from:subject:message-id; bh=N7OQT3pqAHKDCNCAY/LReNVzDP69Zm/S1j6pOUMPwFA=; b=LGbMFTWVUmQMh78UNWdupmVVD8rED3hzcHA2UWrPq6e9JqwmUpHEeHTBVp1GzdOMFjyUwnOmA PIoVV/sZ4S3DC6OGxHnrn8DQLNXSv2k1/e3iTVGNbD/W6Bj/dBKDj9i X-Developer-Key: i=shyckless@gmail.com; a=ed25519; pk=pMtccVGiWES3bV+7YBFuBclkvq2n2HBHQ5azaBrK2lY= X-Endpoint-Received: by B4 Relay for shyckless@gmail.com/default with auth_id=1498 X-Original-From: Suyuan Wang Reply-To: shyckless@gmail.com From: Suyuan Wang kirkwood_cpufreq_probe() gets three clocks with of_clk_get_by_name(): cpu_clk, ddrclk and powersave. None of them is ever released with clk_put(). The error paths only disable and unprepare the clocks, and kirkwood_cpufreq_remove() does the same. So the clock references leak when probe fails (for example on -EPROBE_DEFER) and on every unbind. Add the missing clk_put() calls to the error paths and to remove. The "Unable to prepare" paths now jump to new labels that only put the clock that failed to enable. Found with a static analysis tool and checked by hand. Fixes: 2a4bd9f0db24 ("cpufreq: kirkwood: Add a cpufreq driver for Marvell K= irkwood SoCs") Reviewed-by: Zhongqiu Han Co-developed-by: Kaixuan Li Signed-off-by: Kaixuan Li Signed-off-by: Suyuan Wang --- drivers/cpufreq/kirkwood-cpufreq.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/drivers/cpufreq/kirkwood-cpufreq.c b/drivers/cpufreq/kirkwood-= cpufreq.c index 24b285cbeb8d..e85658081c07 100644 --- a/drivers/cpufreq/kirkwood-cpufreq.c +++ b/drivers/cpufreq/kirkwood-cpufreq.c @@ -125,7 +125,7 @@ static int kirkwood_cpufreq_probe(struct platform_devic= e *pdev) err =3D clk_prepare_enable(priv.cpu_clk); if (err) { dev_err(priv.dev, "Unable to prepare cpuclk\n"); - goto out_node; + goto out_put_cpu; } =20 kirkwood_freq_table[0].frequency =3D clk_get_rate(priv.cpu_clk) / 1000; @@ -140,7 +140,7 @@ static int kirkwood_cpufreq_probe(struct platform_devic= e *pdev) err =3D clk_prepare_enable(priv.ddr_clk); if (err) { dev_err(priv.dev, "Unable to prepare ddrclk\n"); - goto out_cpu; + goto out_put_ddr; } kirkwood_freq_table[1].frequency =3D clk_get_rate(priv.ddr_clk) / 1000; =20 @@ -153,7 +153,7 @@ static int kirkwood_cpufreq_probe(struct platform_devic= e *pdev) err =3D clk_prepare_enable(priv.powersave_clk); if (err) { dev_err(priv.dev, "Unable to prepare powersave clk\n"); - goto out_ddr; + goto out_put_powersave; } =20 err =3D cpufreq_register_driver(&kirkwood_cpufreq_driver); @@ -167,10 +167,16 @@ static int kirkwood_cpufreq_probe(struct platform_dev= ice *pdev) =20 out_powersave: clk_disable_unprepare(priv.powersave_clk); +out_put_powersave: + clk_put(priv.powersave_clk); out_ddr: clk_disable_unprepare(priv.ddr_clk); +out_put_ddr: + clk_put(priv.ddr_clk); out_cpu: clk_disable_unprepare(priv.cpu_clk); +out_put_cpu: + clk_put(priv.cpu_clk); out_node: of_node_put(np); =20 @@ -182,8 +188,11 @@ static void kirkwood_cpufreq_remove(struct platform_de= vice *pdev) cpufreq_unregister_driver(&kirkwood_cpufreq_driver); =20 clk_disable_unprepare(priv.powersave_clk); + clk_put(priv.powersave_clk); clk_disable_unprepare(priv.ddr_clk); + clk_put(priv.ddr_clk); clk_disable_unprepare(priv.cpu_clk); + clk_put(priv.cpu_clk); } =20 static struct platform_driver kirkwood_cpufreq_platform_driver =3D { --=20 2.34.1 From nobody Mon Nov 23 10:33:12 2026 Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=100.103.45.18 ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1795412456; b=ey4v5F/S7dkTuOsVNj7HA2iaQ3upTL4GQNXrYGl+QBRk/dan+RYDJ+KeIXLwg1VN/73x r+ZWA03HqhB5igLKcbtsd3dyyudwbD58kmyVqIK4ae+z39RoMZRih/KJxsPchRKpANLPf TCBQH9hpClnTms/tuy7QxNdz3aYWW+oNjVf/ahdeFyUTaNKn1OE0M2MD+Bi/iRPDop1l4 DEY4umtK2HN88fnWWhaW1RSzHqMD5VryFjE5YUgZE54Yw0yMCN03yJ5/YE0WIu5POPg2I vV4kugHkP6AhB95dijl/rPah6g66GVcx+mvlxzH0IIcc28/fLdIe+prSVAqNMcAUDLw== ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795412456; h=Received:DKIM-Signature:Received:From:Date:Subject:MIME-Version: Content-Type:Content-Transfer-Encoding:Message-Id:References: In-Reply-To:To:Cc:X-Mailer:X-Developer-Signature:X-Developer-Key: X-Endpoint-Received:X-Original-From:Reply-To; bh=VCAHJAZ8lG0qePrCTaZNQY2oEqKkFnjfl6hdH6oURSQ=; b=aY++Duj1xwnSbFlLkiCJ8UhbXfvvmnQ/6YAOcdkJbq6KJ/twgBsLP0cW39hUlKkuBqVU VYPv+7yxEM+RXVyGB4CULINwRzfabr1QvNUn/vWdgYnNhqSvh9fu2pfSNXUlvWG+VrYyI XBKgb7s8c9IaU0OIOJshKyjt94O2MgJuwf8nzfVpAeNOZ2Q89eAjCH9HQ2lK8eUdLR+bG 8cGCqnWpEepaC3fRMjpIx1m8scqieSMZDTAbfFIiPNh4ivXRst/nnMOFEMyCPZ7qQ6iPR j76sRTEADNzDnOqq8ouqF2cJDqQenpvXNMc8clAQ98WXutfLvrbdzvKpJOuu9MshtEg== ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Gdrvj8eG; arc=pass header.oldest-pass=0 smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 41E08606A33A; Mon, 23 Nov 2026 05:40:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Gdrvj8eG Authentication-Results: smtp.kernel.org; arc=none smtp.remote-ip=100.80.115.77 ARC-Seal: i=1; d=kernel.org; s=arc20260519; a=rsa-sha256; cv=none; t=1795412455; b=uS4fRJmGTnpSeoS+2NBSp01mq/WMjg1MSIEbvb3MWp6KmyQl5LabJq6SNYsKwnYiaWNG 3eSRtgITX+4lXex4o5XiWQ4wXQqpbikDiI02uLV0uJSw+oIa9oSL3IPWn/BwM32TfA/Ct 9DH1zqkIByPvzSN3spcwrF22+LqItSSs/N/jBj9SerSy/cx5CfCe66VcceII2kBovxWb/ d12553f1KAIh2NNHT/Ws+RvzdhP3GR6kpycPIZDxUUHjGAgwahQUp580dPD5Ynm+VHMzr YyU0zZBtw0Eld2MhSmUDJaxteM6rhU+g8sTGBIta9XdMLUs4tV+HVxLErcVdnU2WEQA== ARC-Message-Signature: i=1; d=kernel.org; s=arc20260519; a=rsa-sha256; c=relaxed/relaxed; t=1795412455; h=DKIM-Signature:Received:From:Date:Subject:MIME-Version:Content-Type: Content-Transfer-Encoding:Message-Id:References:In-Reply-To:To:Cc: X-Mailer:X-Developer-Signature:X-Developer-Key:X-Endpoint-Received: X-Original-From:Reply-To; bh=VCAHJAZ8lG0qePrCTaZNQY2oEqKkFnjfl6hdH6oURSQ=; b=SKj4K7BH+8BnCqse3I/8S+kCUwvaKGHYOh+k5cyS3guRXpXpMobs1bNw5/oqNoM5z0g+ uvrIp+IB9wMk1JdQB3TRIvS27CPrfCLxZK7E8zpNQt/+8rWVqjZ8EA+/jEokk6lxXp/wF aJbLe7Wml623cWPFF1+1mWIEbOqbXB12FuMQWXoIio+yuDeWrZQiV+iiM+NbHKFGjLsk4 /1GzbXAsqq4G5grrGkw5SLMscKjIZP5gW8MIgwh0TtBSzpl1xri7MxsH+40RbhOvo4mNe nwaHe86t4jQ1ovRrgVG7ZL92DJfH7UjNtO/J+B2OL2Vv519FZP/Q5EZuPaPqM+eI6ig== ARC-Authentication-Results: i=1; smtp.kernel.org; arc=none smtp.remote-ip=100.80.115.77 Received: from lkml.kernel.org (nexus.subspace.kernel.org [100.80.115.77]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.kernel.org (Postfix) with ESMTPS id 6DEA21F000C6; Mon, 23 Nov 2026 05:40:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795412455; bh=VCAHJAZ8lG0qePrCTaZNQY2oEqKkFnjfl6hdH6oURSQ=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To; b=Gdrvj8eG6KTaIH2jc42QfVaAH+sEp0SsSK8n3aHRS40vqPF+1Mb1czm2Y/mx7m7Gi X1I+MNYH9QED9jg3wi1u3UYVNrPkFA9ZCRssrtleHvfraT3ONOXu+LskZ15215e+Oa j2Zf9pDiMoSVKh8pqdgLpCg/RlXH9GC/1XDdniiwWlJaHB9ykHazFWm+TsOsFR+P7l mrILc6QWb21z0nL16amd0IPjfCCUE/EzdLjPeqQwoMxLBMnJPYuU7i9MSS6IWjkrS+ 5QMgS4vcaijB/TmCngGzx7A2ce74Lj10QYaPYtd2AXe3UrRGq1ZGHoUaXSqbDvdL65 XRyPl8X6Atknw== Received: from nexus.subspace.kernel.org (localhost [IPv6:::1]) by lkml.kernel.org (Postfix) with ESMTP id F04AA4C37E; Mon, 23 Nov 2026 05:40:44 +0000 (UTC) From: Suyuan Wang via B4 Relay Date: Mon, 23 Nov 2026 05:40:45 +0000 Subject: [PATCH v3 3/3] cpufreq: s5pv210: Fix resource leaks on probe error paths X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261123-cpufreq-leaks-v3-3-1f1e3f4f5a7b@gmail.com> References: <20261123-cpufreq-leaks-v3-0-1f1e3f4f5a7b@gmail.com> In-Reply-To: <20261123-cpufreq-leaks-v3-0-1f1e3f4f5a7b@gmail.com> To: viresh.kumar@linaro.org, krzk@kernel.org, peter.griffin@linaro.org, rafael@kernel.org Cc: linux-kernel@vger.kernel.org, zhongqiu.han@oss.qualcomm.com, alim.akhtar@samsung.com, linux-pm@vger.kernel.org, linux-samsung-soc@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-Mailer: b4 0.15.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1795412443; l=2668; i=shyckless@gmail.com; s=default; h=from:subject:message-id; bh=FvOlF8UNPCa6Xw/nvECVgrxkLK8Otjxui0GXRXiNPfI=; b=YHjoUixbbisRBc20yzJITBCVBkZYoq99jZJO0FlFy11K0ajpexiY8I5rH4vZe9g2XV1PcsZlt TlXpH/WQHxEDku8Z+5OmsqNtWK6YR8uRuwaxQrbnUpfTleDlR2gzNaE X-Developer-Key: i=shyckless@gmail.com; a=ed25519; pk=pMtccVGiWES3bV+7YBFuBclkvq2n2HBHQ5azaBrK2lY= X-Endpoint-Received: by B4 Relay for shyckless@gmail.com/default with auth_id=1498 X-Original-From: Suyuan Wang Reply-To: shyckless@gmail.com From: Suyuan Wang s5pv210_cpufreq_probe() returns the result of cpufreq_register_driver() directly: register_reboot_notifier(&s5pv210_cpufreq_reboot_notifier); return cpufreq_register_driver(&s5pv210_driver); If the registration fails, for example because s5pv210_cpu_init() fails, the resources taken by the probe itself are leaked: the two regulators and the clock and DMC register mappings. The reboot notifier also stays registered. (s5pv210_cpu_init() releases its own clocks on its error paths, and the cpufreq core tears down its own state.) Also, when a DMC node has a bad alias, the code jumps to err_clk_base and skips unmapping DMC registers that were already mapped for an earlier node. Unregister the reboot notifier and go through the existing unwind code when cpufreq_register_driver() fails, and jump to err_dmc on the alias error. The err_clk_base label has no users after this, so drop it. Found with a static analysis tool and checked by hand. Fixes: e8b4c1986efb ("[CPUFREQ] S5PV210: Add arm/int voltage control suppor= t") Fixes: fe7f1bcbff91 ("[CPUFREQ] S5PV210: Add reboot notifier to prevent sys= tem hang") Fixes: 6d4ed0f46af6 ("cpufreq: s5pv210: Make the driver multiplatform aware= ") Co-developed-by: Kaixuan Li Signed-off-by: Kaixuan Li Signed-off-by: Suyuan Wang Reviewed-by: Zhongqiu Han --- drivers/cpufreq/s5pv210-cpufreq.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/drivers/cpufreq/s5pv210-cpufreq.c b/drivers/cpufreq/s5pv210-cp= ufreq.c index e64e84e1ee79..29b1c5d71a8b 100644 --- a/drivers/cpufreq/s5pv210-cpufreq.c +++ b/drivers/cpufreq/s5pv210-cpufreq.c @@ -634,7 +634,7 @@ static int s5pv210_cpufreq_probe(struct platform_device= *pdev) if (id < 0 || id >=3D ARRAY_SIZE(dmc_base)) { dev_err(dev, "failed to get alias of dmc node '%pOFn'\n", dmc); result =3D id; - goto err_clk_base; + goto err_dmc; } =20 dmc_base[id] =3D of_iomap(dmc, 0); @@ -655,7 +655,14 @@ static int s5pv210_cpufreq_probe(struct platform_devic= e *pdev) =20 register_reboot_notifier(&s5pv210_cpufreq_reboot_notifier); =20 - return cpufreq_register_driver(&s5pv210_driver); + result =3D cpufreq_register_driver(&s5pv210_driver); + if (result) + goto err_reboot_notifier; + + return 0; + +err_reboot_notifier: + unregister_reboot_notifier(&s5pv210_cpufreq_reboot_notifier); =20 err_dmc: for (id =3D 0; id < ARRAY_SIZE(dmc_base); ++id) @@ -664,7 +671,6 @@ static int s5pv210_cpufreq_probe(struct platform_device= *pdev) dmc_base[id] =3D NULL; } =20 -err_clk_base: iounmap(clk_base); =20 err_clock: --=20 2.34.1