Message ID | 20190219120427.GA26719@kadam (mailing list archive) |
---|---|
State | Accepted |
Commit | a6d9cef30eb11b2de8cbfed9065e3dc5b1f829a8 |
Headers | show |
Series | ASoC: dapm: Potential small memory leak in dapm_cnew_widget() | expand |
On 2/19/19 6:04 AM, Dan Carpenter wrote: > 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> Good catch, thanks. Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.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; > }
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; }
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(-)