lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20260110195337.2522347-1-harshit.m.mogalapalli@oracle.com>
Date: Sat, 10 Jan 2026 11:53:36 -0800
From: Harshit Mogalapalli <harshit.m.mogalapalli@...cle.com>
To: David Rhodes <david.rhodes@...rus.com>,
        Richard Fitzgerald <rf@...nsource.cirrus.com>,
        Liam Girdwood <lgirdwood@...il.com>, Mark Brown <broonie@...nel.org>,
        Jaroslav Kysela <perex@...ex.cz>, Takashi Iwai <tiwai@...e.com>,
        Herve Codina <herve.codina@...tlin.com>,
        Alexander Sverdlin <alexander.sverdlin@...il.com>,
        Pascal Huerst <pascal.huerst@...il.com>, linux-sound@...r.kernel.org,
        patches@...nsource.cirrus.com, linux-kernel@...r.kernel.org
Cc: dan.carpenter@...aro.org, kernel-janitors@...r.kernel.org,
        error27@...il.com,
        Harshit Mogalapalli <harshit.m.mogalapalli@...cle.com>
Subject: [PATCH] ASoC: cs4271: Fix resource leak in cs4271_soc_resume()

Smatch detects this resource leak:

sound/soc/codecs/cs4271.c:548 cs4271_soc_resume() warn:
 'cs4271->clk' from clk_prepare_enable() not released on lines: 540,546.

Instead of direct returns, unprepare the clock and disable regulators on
the error paths.

Fixes: cf6bf51b5325 ("ASoC: cs4271: Add support for the external mclk")
Fixes: 9a397f473657 ("ASoC: cs4271: add regulator consumer support")
Signed-off-by: Harshit Mogalapalli <harshit.m.mogalapalli@...cle.com>
---
Only compile tested.
---
 sound/soc/codecs/cs4271.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/sound/soc/codecs/cs4271.c b/sound/soc/codecs/cs4271.c
index 77dfc83a3c01..d8cdd37e9112 100644
--- a/sound/soc/codecs/cs4271.c
+++ b/sound/soc/codecs/cs4271.c
@@ -528,7 +528,7 @@ static int cs4271_soc_resume(struct snd_soc_component *component)
 	ret = clk_prepare_enable(cs4271->clk);
 	if (ret) {
 		dev_err(component->dev, "Failed to enable clk: %d\n", ret);
-		return ret;
+		goto err_disable_regulators;
 	}
 
 	/* Do a proper reset after power up */
@@ -537,15 +537,21 @@ static int cs4271_soc_resume(struct snd_soc_component *component)
 	/* Restore codec state */
 	ret = regcache_sync(cs4271->regmap);
 	if (ret < 0)
-		return ret;
+		goto err_disable_clk;
 
 	/* then disable the power-down bit */
 	ret = regmap_update_bits(cs4271->regmap, CS4271_MODE2,
 				 CS4271_MODE2_PDN, 0);
 	if (ret < 0)
-		return ret;
+		goto err_disable_clk;
 
 	return 0;
+
+err_disable_clk:
+	clk_disable_unprepare(cs4271->clk);
+err_disable_regulators:
+	regulator_bulk_disable(ARRAY_SIZE(cs4271->supplies), cs4271->supplies);
+	return ret;
 }
 #else
 #define cs4271_soc_suspend	NULL
-- 
2.47.3


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ