From mboxrd@z Thu Jan 1 00:00:00 1970 From: Takashi Iwai Subject: Re: [PATCH 4/5] ALSA: usb-audio: deallocate memory objects in error path Date: Mon, 20 Feb 2017 21:49:19 +0100 Message-ID: References: <20170220200921.824-1-o-takashi@sakamocchi.jp> <20170220200921.824-5-o-takashi@sakamocchi.jp> Mime-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by alsa0.perex.cz (Postfix) with ESMTP id 485B6266B26 for ; Mon, 20 Feb 2017 21:49:20 +0100 (CET) In-Reply-To: <20170220200921.824-5-o-takashi@sakamocchi.jp> 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: Takashi Sakamoto Cc: onkel@paraair.de, alsa-devel@alsa-project.org List-Id: alsa-devel@alsa-project.org On Mon, 20 Feb 2017 21:09:20 +0100, Takashi Sakamoto wrote: > > Some functions for quirks of Tascam US-16x08 have memory leaks. > > This commit fixes the bugs. > > Fixes: d2bb390a2081 ("ALSA: usb-audio: Tascam US-16x08 DSP mixer quirk") > Signed-off-by: Takashi Sakamoto > --- > sound/usb/mixer_us16x08.c | 27 ++++++++++++++++----------- > 1 file changed, 16 insertions(+), 11 deletions(-) > > diff --git a/sound/usb/mixer_us16x08.c b/sound/usb/mixer_us16x08.c > index 5dae63c..d34dd1c 100644 > --- a/sound/usb/mixer_us16x08.c > +++ b/sound/usb/mixer_us16x08.c > @@ -1082,8 +1082,8 @@ static int add_new_ctl(struct usb_mixer_interface *mixer, > > kctl = snd_ctl_new1(ncontrol, elem); > if (!kctl) { > - kfree(elem); > - return -ENOMEM; > + err = -ENOMEM; > + goto end; > } > > kctl->private_free = freeer; > @@ -1092,11 +1092,12 @@ static int add_new_ctl(struct usb_mixer_interface *mixer, > > err = snd_usb_mixer_add_control(&elem->head, kctl); > if (err < 0) > - return err; > + goto end; > > if (elem_ret) > *elem_ret = elem; > - > +end: > + kfree(elem); > return 0; This will release elem even for the success case, no? Takashi