Commit a41d9dbf authored by Dan Carpenter's avatar Dan Carpenter Committed by Mark Brown

ASoC: qdsp6: q6asm-dai: Fix a small memory leak

We can't return directly if snd_dma_alloc_pages() fails; we first need
to free prtd->audio_client and prtd.

Fixes: 22930c79 ("ASoC: qdsp6: q6asm-dai: Add support to compress offload")
Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: default avatarMark Brown <broonie@kernel.org>
parent 3391034e
...@@ -573,8 +573,7 @@ static int q6asm_dai_compr_open(struct snd_compr_stream *stream) ...@@ -573,8 +573,7 @@ static int q6asm_dai_compr_open(struct snd_compr_stream *stream)
if (IS_ERR(prtd->audio_client)) { if (IS_ERR(prtd->audio_client)) {
dev_err(dev, "Could not allocate memory\n"); dev_err(dev, "Could not allocate memory\n");
ret = PTR_ERR(prtd->audio_client); ret = PTR_ERR(prtd->audio_client);
kfree(prtd); goto free_prtd;
return ret;
} }
size = COMPR_PLAYBACK_MAX_FRAGMENT_SIZE * size = COMPR_PLAYBACK_MAX_FRAGMENT_SIZE *
...@@ -583,7 +582,7 @@ static int q6asm_dai_compr_open(struct snd_compr_stream *stream) ...@@ -583,7 +582,7 @@ static int q6asm_dai_compr_open(struct snd_compr_stream *stream)
&prtd->dma_buffer); &prtd->dma_buffer);
if (ret) { if (ret) {
dev_err(dev, "Cannot allocate buffer(s)\n"); dev_err(dev, "Cannot allocate buffer(s)\n");
return ret; goto free_client;
} }
if (pdata->sid < 0) if (pdata->sid < 0)
...@@ -596,6 +595,13 @@ static int q6asm_dai_compr_open(struct snd_compr_stream *stream) ...@@ -596,6 +595,13 @@ static int q6asm_dai_compr_open(struct snd_compr_stream *stream)
runtime->private_data = prtd; runtime->private_data = prtd;
return 0; return 0;
free_client:
q6asm_audio_client_free(prtd->audio_client);
free_prtd:
kfree(prtd);
return ret;
} }
static int q6asm_dai_compr_free(struct snd_compr_stream *stream) static int q6asm_dai_compr_free(struct snd_compr_stream *stream)
......
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