Re: [PATCH 4/5] ALSA: usb-audio: deallocate memory objects in error path

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 <o-takashi@xxxxxxxxxxxxx>
> ---
>  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
_______________________________________________
Alsa-devel mailing list
Alsa-devel@xxxxxxxxxxxxxxxx
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel



[Index of Archives]     [ALSA User]     [Linux Audio Users]     [Kernel Archive]     [Asterisk PBX]     [Photo Sharing]     [Linux Sound]     [Video 4 Linux]     [Gimp]     [Yosemite News]

  Powered by Linux