lkml.org 
[lkml]   [2023]   [Sep]   [3]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] ALSA: scarlett2: Fix a potential memory leak in scarlett2_init_notify()
Date
If kmalloc() fails, we should release 'mixer->urb'.

Fixes: 9e4d5c1be21f ("ALSA: usb-audio: Scarlett Gen 2 mixer interface")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.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
\
 
 \ /
  Last update: 2023-09-03 14:42    [W:0.987 / U:0.020 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site