public inbox for kernel-janitors@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ASoC: dapm: Potential small memory leak in dapm_cnew_widget()
@ 2019-02-19 12:04 Dan Carpenter
  2019-02-19 15:50 ` Applied "ASoC: dapm: Potential small memory leak in dapm_cnew_widget()" to the asoc tree Mark Brown
  2019-02-19 15:59 ` [alsa-devel] [PATCH] ASoC: dapm: Potential small memory leak in dapm_cnew_widget() Pierre-Louis Bossart
  0 siblings, 2 replies; 3+ messages in thread
From: Dan Carpenter @ 2019-02-19 12:04 UTC (permalink / raw)
  To: Liam Girdwood, Pierre-Louis Bossart
  Cc: alsa-devel, Mark Brown, kernel-janitors, Takashi Iwai

We should free "w" on the error path.

Fixes: 199ed3e81c49 ("ASoC: dapm: fix use-after-free issue with dailink sname")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
 sound/soc/soc-dapm.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c
index dea6fc2353e4..1ec06ef6d161 100644
--- a/sound/soc/soc-dapm.c
+++ b/sound/soc/soc-dapm.c
@@ -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;
 }
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-02-19 15:59 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-02-19 12:04 [PATCH] ASoC: dapm: Potential small memory leak in dapm_cnew_widget() Dan Carpenter
2019-02-19 15:50 ` Applied "ASoC: dapm: Potential small memory leak in dapm_cnew_widget()" to the asoc tree Mark Brown
2019-02-19 15:59 ` [alsa-devel] [PATCH] ASoC: dapm: Potential small memory leak in dapm_cnew_widget() Pierre-Louis Bossart

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox