Skip to content

Commit fef1f75

Browse files
harshimogalapallibroonie
authored andcommitted
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: cf6bf51 ("ASoC: cs4271: Add support for the external mclk") Fixes: 9a397f4 ("ASoC: cs4271: add regulator consumer support") Signed-off-by: Harshit Mogalapalli <harshit.m.mogalapalli@oracle.com> Reviewed-by: Charles Keepax <ckeepax@opensource.cirrus.com> Acked-by: Herve Codina <herve.codina@bootlin.com> Reviewed-by: Alexander Sverdlin <alexander.sverdlin@gmail.com> Link: https://patch.msgid.link/20260110195337.2522347-1-harshit.m.mogalapalli@oracle.com Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent dc8384d commit fef1f75

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

sound/soc/codecs/cs4271.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -528,7 +528,7 @@ static int cs4271_soc_resume(struct snd_soc_component *component)
528528
ret = clk_prepare_enable(cs4271->clk);
529529
if (ret) {
530530
dev_err(component->dev, "Failed to enable clk: %d\n", ret);
531-
return ret;
531+
goto err_disable_regulators;
532532
}
533533

534534
/* Do a proper reset after power up */
@@ -537,15 +537,21 @@ static int cs4271_soc_resume(struct snd_soc_component *component)
537537
/* Restore codec state */
538538
ret = regcache_sync(cs4271->regmap);
539539
if (ret < 0)
540-
return ret;
540+
goto err_disable_clk;
541541

542542
/* then disable the power-down bit */
543543
ret = regmap_update_bits(cs4271->regmap, CS4271_MODE2,
544544
CS4271_MODE2_PDN, 0);
545545
if (ret < 0)
546-
return ret;
546+
goto err_disable_clk;
547547

548548
return 0;
549+
550+
err_disable_clk:
551+
clk_disable_unprepare(cs4271->clk);
552+
err_disable_regulators:
553+
regulator_bulk_disable(ARRAY_SIZE(cs4271->supplies), cs4271->supplies);
554+
return ret;
549555
}
550556
#else
551557
#define cs4271_soc_suspend NULL

0 commit comments

Comments
 (0)