Blob Blame History Raw
From f3ee9096fcaf55eae37dfb58603c4dbff6f0a7c9 Mon Sep 17 00:00:00 2001
From: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Date: Thu, 14 Sep 2017 22:44:24 +0200
Subject: [PATCH] ASoC: topology: Fix a potential memory leak in 'soc_tplg_dapm_widget_denum_create()'
Git-commit: f3ee9096fcaf55eae37dfb58603c4dbff6f0a7c9
Patch-mainline: v4.14-rc8
References: bsc#1051510

If this sanity check fails, we must free the memory that has already been
allocated.

So we must go to 'err' as in the other error handling parth of this
function.

Fixes: 1a7dd6e2f192 ("ASoC: topology: Allow a widget to have multiple enum controls")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Signed-off-by: Mark Brown <broonie@kernel.org>
Acked-by: Takashi Iwai <tiwai@suse.de>

---
 sound/soc/soc-topology.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/sound/soc/soc-topology.c
+++ b/sound/soc/soc-topology.c
@@ -1281,7 +1281,7 @@ static struct snd_kcontrol_new *soc_tplg
 		/* validate kcontrol */
 		if (strnlen(ec->hdr.name, SNDRV_CTL_ELEM_ID_NAME_MAXLEN) ==
 			    SNDRV_CTL_ELEM_ID_NAME_MAXLEN)
-			return NULL;
+			goto err;
 
 		se = kzalloc(sizeof(*se), GFP_KERNEL);
 		if (se == NULL)