From: Dan Carpenter Date: Tue, 19 Feb 2019 12:04:27 +0000 (+0300) Subject: ASoC: dapm: Potential small memory leak in dapm_cnew_widget() X-Git-Tag: v5.1-rc1~148^2~1^2^2~33 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=a6d9cef30eb11b2de8cbfed9065e3dc5b1f829a8;p=thirdparty%2Fkernel%2Flinux.git 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") Signed-off-by: Dan Carpenter Signed-off-by: Mark Brown --- diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c index dea6fc2353e47..1ec06ef6d1616 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; }