Skip to contentSkip to conversation

ASoC: rsnd: don't double free kctrl

PATCH In review Colin King 3 participants 3 messages Dec 8, 2016 – Dec 15, 2016

Subsystems (3)
lore
Share & tools
lore

Colin King

author
#0 lore raw

PATCH 1/1 ASoC: rsnd: don't double free kctrl

From: Colin Ian King <[email protected]>

On an error, snd_ctl_add already free's kctrl, so calling snd_ctl_free_one to free it again leads to a double free error. Fix this by removing the extraneous snd_ctl_free_one call.

Issue found using static analysis with CoverityScan, CID 1372908

---
 sound/soc/sh/rcar/core.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
sound/soc/sh/rcar/core.c +1 -3
index 4bd68de..99b5b08 100644
@@ -1030,10 +1030,8 @@ static int __rsnd_kctrl_new(struct rsnd_mod *mod,
 		return -ENOMEM;
 
 	ret = snd_ctl_add(card, kctrl);
-	if (ret < 0) {
-		snd_ctl_free_one(kctrl);
+	if (ret < 0)
 		return ret;
-	}
 
 	cfg->update = update;
 	cfg->card = card;
Signature · 1 line
2.10.2
Acked-by on v1 1/1
#1 lore raw

Hi Colin

Quoted 10 lines

From: Colin Ian King <[email protected]>

On an error, snd_ctl_add already free's kctrl, so calling snd_ctl_free_one to free it again leads to a double free error. Fix this by removing the extraneous snd_ctl_free_one call.

Issue found using static analysis with CoverityScan, CID 1372908

---

Indeed...

If my memory was correct, this code was copied from somewhere...

BTW, in my opinion, function parameter automatically freed in "add" function is a little bit strange behavior for me...

Quoted 22 lines
 sound/soc/sh/rcar/core.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
sound/soc/sh/rcar/core.c +1 -3
index 4bd68de..99b5b08 100644
@@ -1030,10 +1030,8 @@ static int __rsnd_kctrl_new(struct rsnd_mod *mod,
 		return -ENOMEM;
 
 	ret = snd_ctl_add(card, kctrl);
-	if (ret < 0) {
-		snd_ctl_free_one(kctrl);
+	if (ret < 0)
 		return ret;
-	}
 
 	cfg->update = update;
 	cfg->card = card;
Signature · 1 line
2.10.2
maintainer
#2 lore raw

Applied "ASoC: rsnd: don't double free kctrl" to the asoc tree

In reply to Colin King

The patch

ASoC: rsnd: don't double free kctrl

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 0ea617a298dcdc2251b4e10f83ac3f3e627b66e3 Mon Sep 17 00:00:00 2001

From: Colin Ian King <[email protected]>
Date: Thu, 8 Dec 2016 13:05:43 +0000
Subject: [PATCH] ASoC: rsnd: don't double free kctrl

On an error, snd_ctl_add already free's kctrl, so calling snd_ctl_free_one to free it again leads to a double free error. Fix this by removing the extraneous snd_ctl_free_one call.

Issue found using static analysis with CoverityScan, CID 1372908

---
 sound/soc/sh/rcar/core.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
sound/soc/sh/rcar/core.c +1 -3
index 4bd68de76130..99b5b0835c1e 100644
@@ -1030,10 +1030,8 @@ static int __rsnd_kctrl_new(struct rsnd_mod *mod,
 		return -ENOMEM;
 
 	ret = snd_ctl_add(card, kctrl);
-	if (ret < 0) {
-		snd_ctl_free_one(kctrl);
+	if (ret < 0)
 		return ret;
-	}
 
 	cfg->update = update;
 	cfg->card = card;
Signature · 1 line
2.11.0