Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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

authored by

Harshit Mogalapalli and committed by
Mark Brown
fef1f756 dc8384d8

+9 -3
+9 -3
sound/soc/codecs/cs4271.c
··· 528 528 ret = clk_prepare_enable(cs4271->clk); 529 529 if (ret) { 530 530 dev_err(component->dev, "Failed to enable clk: %d\n", ret); 531 - return ret; 531 + goto err_disable_regulators; 532 532 } 533 533 534 534 /* Do a proper reset after power up */ ··· 537 537 /* Restore codec state */ 538 538 ret = regcache_sync(cs4271->regmap); 539 539 if (ret < 0) 540 - return ret; 540 + goto err_disable_clk; 541 541 542 542 /* then disable the power-down bit */ 543 543 ret = regmap_update_bits(cs4271->regmap, CS4271_MODE2, 544 544 CS4271_MODE2_PDN, 0); 545 545 if (ret < 0) 546 - return ret; 546 + goto err_disable_clk; 547 547 548 548 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; 549 555 } 550 556 #else 551 557 #define cs4271_soc_suspend NULL