public inbox for kernel-janitors@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ASoC: cs4271: Fix resource leak in cs4271_soc_resume()
@ 2026-01-10 19:53 Harshit Mogalapalli
  2026-01-10 20:12 ` Alexander Sverdlin
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Harshit Mogalapalli @ 2026-01-10 19:53 UTC (permalink / raw)
  To: David Rhodes, Richard Fitzgerald, Liam Girdwood, Mark Brown,
	Jaroslav Kysela, Takashi Iwai, Herve Codina, Alexander Sverdlin,
	Pascal Huerst, linux-sound, patches, linux-kernel
  Cc: dan.carpenter, kernel-janitors, error27, Harshit Mogalapalli

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@oracle.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


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] ASoC: cs4271: Fix resource leak in cs4271_soc_resume()
  2026-01-10 19:53 [PATCH] ASoC: cs4271: Fix resource leak in cs4271_soc_resume() Harshit Mogalapalli
@ 2026-01-10 20:12 ` Alexander Sverdlin
  2026-01-12  7:24 ` Herve Codina
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Alexander Sverdlin @ 2026-01-10 20:12 UTC (permalink / raw)
  To: Harshit Mogalapalli, David Rhodes, Richard Fitzgerald,
	Liam Girdwood, Mark Brown, Jaroslav Kysela, Takashi Iwai,
	Herve Codina, Pascal Huerst, linux-sound, patches, linux-kernel
  Cc: dan.carpenter, kernel-janitors, error27

Thanks for the patch Harshit!

On Sat, 2026-01-10 at 11:53 -0800, Harshit Mogalapalli wrote:
> 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@oracle.com>

Reviewed-by: Alexander Sverdlin <alexander.sverdlin@gmail.com>

> ---
> Only compile tested.
> ---
>  sound/soc/codecs/cs4271.c | 12 +++++++++---
>  1 file changed, 9 insertions(+), 3 deletions(-)

-- 
Alexander Sverdlin.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] ASoC: cs4271: Fix resource leak in cs4271_soc_resume()
  2026-01-10 19:53 [PATCH] ASoC: cs4271: Fix resource leak in cs4271_soc_resume() Harshit Mogalapalli
  2026-01-10 20:12 ` Alexander Sverdlin
@ 2026-01-12  7:24 ` Herve Codina
  2026-01-12 10:54 ` Charles Keepax
  2026-02-05 17:28 ` Mark Brown
  3 siblings, 0 replies; 5+ messages in thread
From: Herve Codina @ 2026-01-12  7:24 UTC (permalink / raw)
  To: Harshit Mogalapalli
  Cc: David Rhodes, Richard Fitzgerald, Liam Girdwood, Mark Brown,
	Jaroslav Kysela, Takashi Iwai, Alexander Sverdlin, Pascal Huerst,
	linux-sound, patches, linux-kernel, dan.carpenter,
	kernel-janitors, error27

Hi Harshit,

On Sat, 10 Jan 2026 11:53:36 -0800
Harshit Mogalapalli <harshit.m.mogalapalli@oracle.com> wrote:

> 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@oracle.com>
> ---
> Only compile tested.
> ---
>  sound/soc/codecs/cs4271.c | 12 +++++++++---
>  1 file changed, 9 insertions(+), 3 deletions(-)
> 

Thanks for the modification.

Acked-by: Herve Codina <herve.codina@bootlin.com>

Best regards,
Hervé

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] ASoC: cs4271: Fix resource leak in cs4271_soc_resume()
  2026-01-10 19:53 [PATCH] ASoC: cs4271: Fix resource leak in cs4271_soc_resume() Harshit Mogalapalli
  2026-01-10 20:12 ` Alexander Sverdlin
  2026-01-12  7:24 ` Herve Codina
@ 2026-01-12 10:54 ` Charles Keepax
  2026-02-05 17:28 ` Mark Brown
  3 siblings, 0 replies; 5+ messages in thread
From: Charles Keepax @ 2026-01-12 10:54 UTC (permalink / raw)
  To: Harshit Mogalapalli
  Cc: David Rhodes, Richard Fitzgerald, Liam Girdwood, Mark Brown,
	Jaroslav Kysela, Takashi Iwai, Herve Codina, Alexander Sverdlin,
	Pascal Huerst, linux-sound, patches, linux-kernel, dan.carpenter,
	kernel-janitors, error27

On Sat, Jan 10, 2026 at 11:53:36AM -0800, Harshit Mogalapalli wrote:
> 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@oracle.com>
> ---

Reviewed-by: Charles Keepax <ckeepax@opensource.cirrus.com>

Thanks,
Charles

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] ASoC: cs4271: Fix resource leak in cs4271_soc_resume()
  2026-01-10 19:53 [PATCH] ASoC: cs4271: Fix resource leak in cs4271_soc_resume() Harshit Mogalapalli
                   ` (2 preceding siblings ...)
  2026-01-12 10:54 ` Charles Keepax
@ 2026-02-05 17:28 ` Mark Brown
  3 siblings, 0 replies; 5+ messages in thread
From: Mark Brown @ 2026-02-05 17:28 UTC (permalink / raw)
  To: David Rhodes, Richard Fitzgerald, Liam Girdwood, Jaroslav Kysela,
	Takashi Iwai, Herve Codina, Alexander Sverdlin, Pascal Huerst,
	linux-sound, patches, linux-kernel, Harshit Mogalapalli
  Cc: dan.carpenter, kernel-janitors, error27

On Sat, 10 Jan 2026 11:53:36 -0800, Harshit Mogalapalli wrote:
> 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.
> 
> [...]

Applied to

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next

Thanks!

[1/1] ASoC: cs4271: Fix resource leak in cs4271_soc_resume()
      commit: fef1f756155c30511397bbcd9d55640ab2e44d99

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-02-05 17:28 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-10 19:53 [PATCH] ASoC: cs4271: Fix resource leak in cs4271_soc_resume() Harshit Mogalapalli
2026-01-10 20:12 ` Alexander Sverdlin
2026-01-12  7:24 ` Herve Codina
2026-01-12 10:54 ` Charles Keepax
2026-02-05 17:28 ` Mark Brown

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