Skip to content

Commit acadb2e

Browse files
Haoxiang Ligregkh
authored andcommitted
ASoC: codecs: wcd937x: fix a potential memory leak in wcd937x_soc_codec_probe()
commit 3e330ac upstream. When snd_soc_dapm_new_controls() or snd_soc_dapm_add_routes() fails, wcd937x_soc_codec_probe() returns without releasing 'wcd937x->clsh_info', which is allocated by wcd_clsh_ctrl_alloc. Add wcd_clsh_ctrl_free() to prevent potential memory leak. Fixes: 313e978 ("ASoC: codecs: wcd937x: add audio routing and Kconfig") Cc: stable@vger.kernel.org Signed-off-by: Haoxiang Li <haoxiang_li2024@163.com> Link: https://patch.msgid.link/20250226085050.3584898-1-haoxiang_li2024@163.com Signed-off-by: Mark Brown <broonie@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 3e03568 commit acadb2e

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

sound/soc/codecs/wcd937x.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2564,13 +2564,15 @@ static int wcd937x_soc_codec_probe(struct snd_soc_component *component)
25642564
ARRAY_SIZE(wcd9375_dapm_widgets));
25652565
if (ret < 0) {
25662566
dev_err(component->dev, "Failed to add snd_ctls\n");
2567+
wcd_clsh_ctrl_free(wcd937x->clsh_info);
25672568
return ret;
25682569
}
25692570

25702571
ret = snd_soc_dapm_add_routes(dapm, wcd9375_audio_map,
25712572
ARRAY_SIZE(wcd9375_audio_map));
25722573
if (ret < 0) {
25732574
dev_err(component->dev, "Failed to add routes\n");
2575+
wcd_clsh_ctrl_free(wcd937x->clsh_info);
25742576
return ret;
25752577
}
25762578
}

0 commit comments

Comments
 (0)