From mboxrd@z Thu Jan 1 00:00:00 1970 From: Pierre-Louis Bossart Subject: Re: [PATCH] ASoC: dapm: Potential small memory leak in dapm_cnew_widget() Date: Tue, 19 Feb 2019 09:59:07 -0600 Message-ID: References: <20190219120427.GA26719@kadam> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; Format="flowed" Content-Transfer-Encoding: 7bit Return-path: Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by alsa0.perex.cz (Postfix) with ESMTP id 80727265535 for ; Tue, 19 Feb 2019 16:59:10 +0100 (CET) In-Reply-To: <20190219120427.GA26719@kadam> Content-Language: en-US List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org To: Dan Carpenter , Liam Girdwood Cc: alsa-devel@alsa-project.org, Mark Brown , kernel-janitors@vger.kernel.org, Takashi Iwai List-Id: alsa-devel@alsa-project.org 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 Good catch, thanks. Reviewed-by: Pierre-Louis Bossart > --- > 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; > }