Skip to content

Commit 3e330ac

Browse files
Haoxiang Libroonie
authored andcommitted
ASoC: codecs: wcd937x: fix a potential memory leak in wcd937x_soc_codec_probe()
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: [email protected] Signed-off-by: Haoxiang Li <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent ede6445 commit 3e330ac

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
@@ -2571,13 +2571,15 @@ static int wcd937x_soc_codec_probe(struct snd_soc_component *component)
25712571
ARRAY_SIZE(wcd9375_dapm_widgets));
25722572
if (ret < 0) {
25732573
dev_err(component->dev, "Failed to add snd_ctls\n");
2574+
wcd_clsh_ctrl_free(wcd937x->clsh_info);
25742575
return ret;
25752576
}
25762577

25772578
ret = snd_soc_dapm_add_routes(dapm, wcd9375_audio_map,
25782579
ARRAY_SIZE(wcd9375_audio_map));
25792580
if (ret < 0) {
25802581
dev_err(component->dev, "Failed to add routes\n");
2582+
wcd_clsh_ctrl_free(wcd937x->clsh_info);
25812583
return ret;
25822584
}
25832585
}

0 commit comments

Comments
 (0)