All of lore.kernel.org
 help / color / mirror / Atom feed
From: Satendra Singh Thakur <thakursatendra2003@yahoo.co.in>
Cc: alsa-devel@alsa-project.org, Liam Girdwood <lgirdwood@gmail.com>,
	linux-kernel@vger.kernel.org, Takashi Iwai <tiwai@suse.com>,
	Mark Brown <broonie@kernel.org>,
	Satendra Singh Thakur <thakursatendra2003@yahoo.co.in>
Subject: [alsa-devel] [PATCH] [ASoC][soc-dapm] : memory leak in the func snd_soc_dapm_new_dai
Date: Thu, 25 Jul 2019 21:43:35 +0530	[thread overview]
Message-ID: <20190725161335.4162-1-thakursatendra2003@yahoo.co.in> (raw)

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.

Signed-off-by: Satendra Singh Thakur <thakursatendra2003@yahoo.co.in>
---
 sound/soc/soc-dapm.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c
index f013b24c050a..f62d41ee6d68 100644
--- a/sound/soc/soc-dapm.c
+++ b/sound/soc/soc-dapm.c
@@ -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:
-- 
2.17.1

_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel

             reply	other threads:[~2019-07-25 16:17 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-25 16:13 Satendra Singh Thakur [this message]
2019-07-29  8:18 ` [alsa-devel] [PATCH] [ASoC][soc-dapm] : memory leak in the func snd_soc_dapm_new_dai Charles Keepax
2019-07-29  8:18   ` Charles Keepax

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=20190725161335.4162-1-thakursatendra2003@yahoo.co.in \
    --to=thakursatendra2003@yahoo.co.in \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=lgirdwood@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tiwai@suse.com \
    /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.