Commit 09f448a4 authored by Amadeusz Sławiński's avatar Amadeusz Sławiński Committed by Mark Brown

ASoC: compress: Fix memory leak from snd_soc_new_compress

Change kzalloc to devm_kzalloc, so compr gets automatically freed when
it's no longer needed.
Signed-off-by: default avatarAmadeusz Sławiński <amadeuszx.slawinski@linux.intel.com>
Reviewed-by: default avatarPierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: default avatarMark Brown <broonie@kernel.org>
parent 8a5b0177
...@@ -896,16 +896,14 @@ int snd_soc_new_compress(struct snd_soc_pcm_runtime *rtd, int num) ...@@ -896,16 +896,14 @@ int snd_soc_new_compress(struct snd_soc_pcm_runtime *rtd, int num)
else else
direction = SND_COMPRESS_CAPTURE; direction = SND_COMPRESS_CAPTURE;
compr = kzalloc(sizeof(*compr), GFP_KERNEL); compr = devm_kzalloc(rtd->card->dev, sizeof(*compr), GFP_KERNEL);
if (!compr) if (!compr)
return -ENOMEM; return -ENOMEM;
compr->ops = devm_kzalloc(rtd->card->dev, sizeof(soc_compr_ops), compr->ops = devm_kzalloc(rtd->card->dev, sizeof(soc_compr_ops),
GFP_KERNEL); GFP_KERNEL);
if (!compr->ops) { if (!compr->ops)
ret = -ENOMEM; return -ENOMEM;
goto compr_err;
}
if (rtd->dai_link->dynamic) { if (rtd->dai_link->dynamic) {
snprintf(new_name, sizeof(new_name), "(%s)", snprintf(new_name, sizeof(new_name), "(%s)",
...@@ -918,7 +916,7 @@ int snd_soc_new_compress(struct snd_soc_pcm_runtime *rtd, int num) ...@@ -918,7 +916,7 @@ int snd_soc_new_compress(struct snd_soc_pcm_runtime *rtd, int num)
dev_err(rtd->card->dev, dev_err(rtd->card->dev,
"Compress ASoC: can't create compressed for %s: %d\n", "Compress ASoC: can't create compressed for %s: %d\n",
rtd->dai_link->name, ret); rtd->dai_link->name, ret);
goto compr_err; return ret;
} }
rtd->pcm = be_pcm; rtd->pcm = be_pcm;
...@@ -954,7 +952,7 @@ int snd_soc_new_compress(struct snd_soc_pcm_runtime *rtd, int num) ...@@ -954,7 +952,7 @@ int snd_soc_new_compress(struct snd_soc_pcm_runtime *rtd, int num)
dev_err(component->dev, dev_err(component->dev,
"Compress ASoC: can't create compress for codec %s: %d\n", "Compress ASoC: can't create compress for codec %s: %d\n",
component->name, ret); component->name, ret);
goto compr_err; return ret;
} }
/* DAPM dai link stream work */ /* DAPM dai link stream work */
...@@ -965,10 +963,7 @@ int snd_soc_new_compress(struct snd_soc_pcm_runtime *rtd, int num) ...@@ -965,10 +963,7 @@ int snd_soc_new_compress(struct snd_soc_pcm_runtime *rtd, int num)
dev_info(rtd->card->dev, "Compress ASoC: %s <-> %s mapping ok\n", dev_info(rtd->card->dev, "Compress ASoC: %s <-> %s mapping ok\n",
codec_dai->name, cpu_dai->name); codec_dai->name, cpu_dai->name);
return ret;
compr_err: return 0;
kfree(compr);
return ret;
} }
EXPORT_SYMBOL_GPL(snd_soc_new_compress); EXPORT_SYMBOL_GPL(snd_soc_new_compress);
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment