Skip to contentSkip to conversation

ASoC: fix memory leak

PATCH In review Sudip Mukherjee 2 participants 2 messages Feb 22, 2016

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

PATCH 1/1 ASoC: fix memory leak

If dai_link is already bound then we just returned and leaked rtd and rtd->codec_dais which were allocated by soc_new_pcm_runtime(). We do not need this newly allocated rtd to check if dai_link is already binded. Lets check first if it is already binded before allocating this memory.

---
 sound/soc/soc-core.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
sound/soc/soc-core.c +4 -4
index 790ee2b..d2e62b15 100644
@@ -986,16 +986,16 @@ static int soc_bind_dai_link(struct snd_soc_card *card,
 
 	dev_dbg(card->dev, "ASoC: binding %s\n", dai_link->name);
 
-	rtd = soc_new_pcm_runtime(card, dai_link);
-	if (!rtd)
-		return -ENOMEM;
-
 	if (soc_is_dai_link_bound(card, dai_link)) {
 		dev_dbg(card->dev, "ASoC: dai link %s already bound\n",
 			dai_link->name);
 		return 0;
 	}
 
+	rtd = soc_new_pcm_runtime(card, dai_link);
+	if (!rtd)
+		return -ENOMEM;
+
 	cpu_dai_component.name = dai_link->cpu_name;
 	cpu_dai_component.of_node = dai_link->cpu_of_node;
 	cpu_dai_component.dai_name = dai_link->cpu_dai_name;
Signature · 1 line
1.9.1
maintainer
#1 lore raw

Applied "ASoC: fix memory leak" to the asoc tree

The patch

ASoC: fix memory leak

has been applied to the asoc tree at

git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git

All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying to this mail.

Thanks,
Mark

Quoted 1 line

From 513cb31120fb5a5b02d9e42eb1d0a0bf05e227c5 Mon Sep 17 00:00:00 2001

From: Sudip Mukherjee <[email protected]>
Date: Mon, 22 Feb 2016 14:14:31 +0530
Subject: [PATCH] ASoC: fix memory leak

If dai_link is already bound then we just returned and leaked rtd and rtd->codec_dais which were allocated by soc_new_pcm_runtime(). We do not need this newly allocated rtd to check if dai_link is already binded. Lets check first if it is already binded before allocating this memory.

---
 sound/soc/soc-core.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
sound/soc/soc-core.c +4 -4
index 790ee2bf1a47..d2e62b159610 100644
@@ -986,16 +986,16 @@ static int soc_bind_dai_link(struct snd_soc_card *card,
 
 	dev_dbg(card->dev, "ASoC: binding %s\n", dai_link->name);
 
-	rtd = soc_new_pcm_runtime(card, dai_link);
-	if (!rtd)
-		return -ENOMEM;
-
 	if (soc_is_dai_link_bound(card, dai_link)) {
 		dev_dbg(card->dev, "ASoC: dai link %s already bound\n",
 			dai_link->name);
 		return 0;
 	}
 
+	rtd = soc_new_pcm_runtime(card, dai_link);
+	if (!rtd)
+		return -ENOMEM;
+
 	cpu_dai_component.name = dai_link->cpu_name;
 	cpu_dai_component.of_node = dai_link->cpu_of_node;
 	cpu_dai_component.dai_name = dai_link->cpu_dai_name;
Signature · 1 line
2.7.0