Re: [PATCH] ALSA: usb-audio: Fix memory leak in scarlett2_add_new_ctl()

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

 



> When snd_usb_mixer_add_control() fails, elem needs to be
> freed just like when snd_ctl_new1() fails. However, current
> code is returning directly and ends up leaking memory.

Can an imperative wording be preferred for the change description?


…
> +++ b/sound/usb/mixer_scarlett_gen2.c
> @@ -964,8 +964,10 @@  static int scarlett2_add_new_ctl(struct usb_mixer_interface *mixer,
>  	strlcpy(kctl->id.name, name, sizeof(kctl->id.name));
>
>  	err = snd_usb_mixer_add_control(&elem->head, kctl);
> -	if (err < 0)
> +	if (err < 0) {
> +		kfree(elem);
>  		return err;
> +	}
…

I propose to add a jump target so that a bit of common exception handling code
can be better reused in this function implementation.

Regards,
Markus




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

  Powered by Linux