Skip to contentSkip to conversation

ASoC: dapm: Potential small memory leak in dapm_cnew_widget()

PATCH In review Dan Carpenter 3 participants 3 messages Feb 19, 2019

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

PATCH 1/1 ASoC: dapm: Potential small memory leak in dapm_cnew_widget()

We should free "w" on the error path.

Fixes 199ed3e81c49 ("ASoC: dapm: fix use-after-free issue with dailink sname")
---
 sound/soc/soc-dapm.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
sound/soc/soc-dapm.c +3 -1
index dea6fc2353e4..1ec06ef6d161 100644
@@ -332,8 +332,10 @@ static inline struct snd_soc_dapm_widget *dapm_cnew_widget(
 	 */
 	if (_widget->sname) {
 		w->sname = kstrdup_const(_widget->sname, GFP_KERNEL);
-		if (!w->sname)
+		if (!w->sname) {
+			kfree(w);
 			return NULL;
+		}
 	}
 	return w;
 }
Signature · 1 line
2.17.1
maintainer
#1 lore raw

Applied "ASoC: dapm: Potential small memory leak in dapm_cnew_widget()" to the asoc tree

The patch

ASoC: dapm: Potential small memory leak in dapm_cnew_widget()

has been applied to the asoc tree at

https://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

From a6d9cef30eb11b2de8cbfed9065e3dc5b1f829a8 Mon Sep 17 00:00:00 2001
From: Dan Carpenter <[email protected]>
Date: Tue, 19 Feb 2019 15:04:27 +0300
Subject: [PATCH] ASoC: dapm: Potential small memory leak in dapm_cnew_widget()

We should free "w" on the error path.

Fixes 199ed3e81c49 ("ASoC: dapm: fix use-after-free issue with dailink sname")
---
 sound/soc/soc-dapm.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
sound/soc/soc-dapm.c +3 -1
index dea6fc2353e4..1ec06ef6d161 100644
@@ -332,8 +332,10 @@ static inline struct snd_soc_dapm_widget *dapm_cnew_widget(
 	 */
 	if (_widget->sname) {
 		w->sname = kstrdup_const(_widget->sname, GFP_KERNEL);
-		if (!w->sname)
+		if (!w->sname) {
+			kfree(w);
 			return NULL;
+		}
 	}
 	return w;
 }
Signature · 1 line
2.20.1
Reviewed-by on v1 1/1
#2 lore raw
In reply to Dan Carpenter
Quoted 4 lines · Dan Carpenter

We should free "w" on the error path.

Fixes 199ed3e81c49 ("ASoC: dapm: fix use-after-free issue with dailink sname")

Good catch, thanks.

Quoted 20 lines
---
  sound/soc/soc-dapm.c | 4 +++-
  1 file changed, 3 insertions(+), 1 deletion(-)
sound/soc/soc-dapm.c +3 -1
index dea6fc2353e4..1ec06ef6d161 100644
@@ -332,8 +332,10 @@ static inline struct snd_soc_dapm_widget *dapm_cnew_widget(
  	 */
  	if (_widget->sname) {
  		w->sname = kstrdup_const(_widget->sname, GFP_KERNEL);
-		if (!w->sname)
+		if (!w->sname) {
+			kfree(w);
  			return NULL;
+		}
  	}
  	return w;
  }