From: Dan Carpenter <dan.carpenter@oracle.com>
To: Patrick Lai <plai@codeaurora.org>,
Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Cc: alsa-devel@alsa-project.org,
Banajit Goswami <bgoswami@codeaurora.org>,
kernel-janitors@vger.kernel.org, Takashi Iwai <tiwai@suse.com>,
Liam Girdwood <lgirdwood@gmail.com>,
Vinod Koul <vkoul@kernel.org>, Mark Brown <broonie@kernel.org>
Subject: [PATCH 3/4] ASoC: qdsp6: q6asm-dai: Fix a small memory leak
Date: Fri, 21 Dec 2018 12:06:10 +0300 [thread overview]
Message-ID: <20181221090610.GC2735@kadam> (raw)
In-Reply-To: <20181221090442.GA2735@kadam>
We can't return directly if snd_dma_alloc_pages() fails; we first need
to free prtd->audio_client and prtd.
Fixes: 22930c79ac5c ("ASoC: qdsp6: q6asm-dai: Add support to compress offload")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
sound/soc/qcom/qdsp6/q6asm-dai.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/sound/soc/qcom/qdsp6/q6asm-dai.c b/sound/soc/qcom/qdsp6/q6asm-dai.c
index 3407e51b8861..548eb4fa2da6 100644
--- a/sound/soc/qcom/qdsp6/q6asm-dai.c
+++ b/sound/soc/qcom/qdsp6/q6asm-dai.c
@@ -573,8 +573,7 @@ static int q6asm_dai_compr_open(struct snd_compr_stream *stream)
if (IS_ERR(prtd->audio_client)) {
dev_err(dev, "Could not allocate memory\n");
ret = PTR_ERR(prtd->audio_client);
- kfree(prtd);
- return ret;
+ goto free_prtd;
}
size = COMPR_PLAYBACK_MAX_FRAGMENT_SIZE *
@@ -583,7 +582,7 @@ static int q6asm_dai_compr_open(struct snd_compr_stream *stream)
&prtd->dma_buffer);
if (ret) {
dev_err(dev, "Cannot allocate buffer(s)\n");
- return ret;
+ goto free_client;
}
if (pdata->sid < 0)
@@ -596,6 +595,13 @@ static int q6asm_dai_compr_open(struct snd_compr_stream *stream)
runtime->private_data = prtd;
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)
--
2.17.1
WARNING: multiple messages have this Message-ID (diff)
From: Dan Carpenter <dan.carpenter@oracle.com>
To: Patrick Lai <plai@codeaurora.org>,
Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Cc: alsa-devel@alsa-project.org,
Banajit Goswami <bgoswami@codeaurora.org>,
kernel-janitors@vger.kernel.org, Takashi Iwai <tiwai@suse.com>,
Liam Girdwood <lgirdwood@gmail.com>,
Vinod Koul <vkoul@kernel.org>, Mark Brown <broonie@kernel.org>
Subject: [PATCH 3/4] ASoC: qdsp6: q6asm-dai: Fix a small memory leak
Date: Fri, 21 Dec 2018 09:06:10 +0000 [thread overview]
Message-ID: <20181221090610.GC2735@kadam> (raw)
In-Reply-To: <20181221090442.GA2735@kadam>
We can't return directly if snd_dma_alloc_pages() fails; we first need
to free prtd->audio_client and prtd.
Fixes: 22930c79ac5c ("ASoC: qdsp6: q6asm-dai: Add support to compress offload")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
sound/soc/qcom/qdsp6/q6asm-dai.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/sound/soc/qcom/qdsp6/q6asm-dai.c b/sound/soc/qcom/qdsp6/q6asm-dai.c
index 3407e51b8861..548eb4fa2da6 100644
--- a/sound/soc/qcom/qdsp6/q6asm-dai.c
+++ b/sound/soc/qcom/qdsp6/q6asm-dai.c
@@ -573,8 +573,7 @@ static int q6asm_dai_compr_open(struct snd_compr_stream *stream)
if (IS_ERR(prtd->audio_client)) {
dev_err(dev, "Could not allocate memory\n");
ret = PTR_ERR(prtd->audio_client);
- kfree(prtd);
- return ret;
+ goto free_prtd;
}
size = COMPR_PLAYBACK_MAX_FRAGMENT_SIZE *
@@ -583,7 +582,7 @@ static int q6asm_dai_compr_open(struct snd_compr_stream *stream)
&prtd->dma_buffer);
if (ret) {
dev_err(dev, "Cannot allocate buffer(s)\n");
- return ret;
+ goto free_client;
}
if (pdata->sid < 0)
@@ -596,6 +595,13 @@ static int q6asm_dai_compr_open(struct snd_compr_stream *stream)
runtime->private_data = prtd;
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)
--
2.17.1
next prev parent reply other threads:[~2018-12-21 9:06 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-12-21 9:04 [PATCH 1/2] ASoC: qdsp6: q6asm-dai: Off by one in of_q6asm_parse_dai_data() Dan Carpenter
2018-12-21 9:04 ` Dan Carpenter
2018-12-21 9:05 ` [PATCH 2/2] ASoC: qdsp6: q6asm-dai: Fix a NULL vs IS_ERR() bug Dan Carpenter
2018-12-21 9:05 ` Dan Carpenter
2018-12-21 12:29 ` Srinivas Kandagatla
2018-12-21 13:42 ` Applied "ASoC: qdsp6: q6asm-dai: Fix a NULL vs IS_ERR() bug" to the asoc tree Mark Brown
2018-12-21 13:42 ` Mark Brown
2018-12-21 9:06 ` Dan Carpenter [this message]
2018-12-21 9:06 ` [PATCH 3/4] ASoC: qdsp6: q6asm-dai: Fix a small memory leak Dan Carpenter
2018-12-21 12:29 ` Srinivas Kandagatla
2018-12-21 12:29 ` [alsa-devel] " Srinivas Kandagatla
2018-12-21 13:42 ` Applied "ASoC: qdsp6: q6asm-dai: Fix a small memory leak" to the asoc tree Mark Brown
2018-12-21 13:42 ` Mark Brown
2018-12-21 9:06 ` [PATCH 4/4] ALSA: compress: prevent potential divide by zero bugs Dan Carpenter
2018-12-21 9:06 ` Dan Carpenter
2018-12-21 13:42 ` Applied "ALSA: compress: prevent potential divide by zero bugs" to the asoc tree Mark Brown
2018-12-21 13:42 ` Mark Brown
2018-12-21 12:31 ` [PATCH 1/2] ASoC: qdsp6: q6asm-dai: Off by one in of_q6asm_parse_dai_data() Srinivas Kandagatla
2018-12-21 13:42 ` Applied "ASoC: qdsp6: q6asm-dai: Off by one in of_q6asm_parse_dai_data()" to the asoc tree Mark Brown
2018-12-21 13:42 ` Mark Brown
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20181221090610.GC2735@kadam \
--to=dan.carpenter@oracle.com \
--cc=alsa-devel@alsa-project.org \
--cc=bgoswami@codeaurora.org \
--cc=broonie@kernel.org \
--cc=kernel-janitors@vger.kernel.org \
--cc=lgirdwood@gmail.com \
--cc=plai@codeaurora.org \
--cc=srinivas.kandagatla@linaro.org \
--cc=tiwai@suse.com \
--cc=vkoul@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.