Skip to contentSkip to conversation

: memory leak in the func snd_soc_dapm_new_dai

PATCH New Satendra Singh Thakur 1 participant 1 message Jul 26, 2019

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 : memory leak in the func snd_soc_dapm_new_dai

In the func snd_soc_dapm_new_dai, if the inner func snd_soc_dapm_alloc_kcontrol fails, there will be memory leak. The label param_fail wont free memory which is allocated by the func devm_kcalloc. Hence new label is created for this purpose.

---
 sound/soc/soc-dapm.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
sound/soc/soc-dapm.c +2 -1
index f013b24c050a..f62d41ee6d68 100644
@@ -4095,7 +4095,7 @@ snd_soc_dapm_new_dai(struct snd_soc_card *card, struct snd_soc_pcm_runtime *rtd,
 						w_param_text, &private_value);
 		if (!template.kcontrol_news) {
 			ret = -ENOMEM;
-			goto param_fail;
+			goto outfree_w_param;
 		}
 	} else {
 		w_param_text = NULL;
@@ -4114,6 +4114,7 @@ snd_soc_dapm_new_dai(struct snd_soc_card *card, struct snd_soc_pcm_runtime *rtd,
 
 outfree_kcontrol_news:
 	devm_kfree(card->dev, (void *)template.kcontrol_news);
+outfree_w_param:
 	snd_soc_dapm_free_kcontrol(card, &private_value,
 				   rtd->dai_link->num_params, w_param_text);
 param_fail:
Signature · 1 line
2.17.1