lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <87zg23l4bn.wl-tiwai@suse.de>
Date:   Sun, 03 Sep 2023 16:27:40 +0200
From:   Takashi Iwai <tiwai@...e.de>
To:     Christophe JAILLET <christophe.jaillet@...adoo.fr>
Cc:     "Geoffrey D. Bennett" <g@...vu>, Jaroslav Kysela <perex@...ex.cz>,
        Takashi Iwai <tiwai@...e.com>, linux-kernel@...r.kernel.org,
        kernel-janitors@...r.kernel.org, alsa-devel@...a-project.org
Subject: Re: [PATCH] ALSA: scarlett2: Fix a potential memory leak in scarlett2_init_notify()

On Sun, 03 Sep 2023 14:41:45 +0200,
Christophe JAILLET wrote:
> 
> If kmalloc() fails, we should release 'mixer->urb'.

This is released at the common error path in mixer.c,
snd_usb_mixer_free(), hence it's not needed.

And, even if freeing here, you must NULL-clear mixer->urb, too;
otherwise it'll lead to double-free.


thanks,

Takashi

> 
> Fixes: 9e4d5c1be21f ("ALSA: usb-audio: Scarlett Gen 2 mixer interface")
> Signed-off-by: Christophe JAILLET <christophe.jaillet@...adoo.fr>
> ---
>  sound/usb/mixer_scarlett_gen2.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/sound/usb/mixer_scarlett_gen2.c b/sound/usb/mixer_scarlett_gen2.c
> index 9d11bb08667e..a439c7f64b2e 100644
> --- a/sound/usb/mixer_scarlett_gen2.c
> +++ b/sound/usb/mixer_scarlett_gen2.c
> @@ -4060,8 +4060,10 @@ static int scarlett2_init_notify(struct usb_mixer_interface *mixer)
>  		return -ENOMEM;
>  
>  	transfer_buffer = kmalloc(private->wMaxPacketSize, GFP_KERNEL);
> -	if (!transfer_buffer)
> +	if (!transfer_buffer) {
> +		usb_free_urb(mixer->urb);
>  		return -ENOMEM;
> +	}
>  
>  	usb_fill_int_urb(mixer->urb, dev, pipe,
>  			 transfer_buffer, private->wMaxPacketSize,
> -- 
> 2.34.1
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ