Skip to content

Commit

Permalink
ALSA: usx2y: Fix potential NULL pointer dereference
Browse files Browse the repository at this point in the history
usb_alloc_urb() can fail due to kmalloc failure and push the error
upstream. Further this can cause a NULL pointer dereference in
init_pipe_urbs(). This patch avoids such a scenario.

Signed-off-by: Aditya Pakki <pakki001@umn.edu>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
  • Loading branch information
Aditya Pakki authored and tiwai committed Mar 13, 2019
1 parent d344e07 commit a2c6433
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions sound/usb/usx2y/usb_stream.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,12 @@ static int init_urbs(struct usb_stream_kernel *sk, unsigned use_packsize,

for (u = 0; u < USB_STREAM_NURBS; ++u) {
sk->inurb[u] = usb_alloc_urb(sk->n_o_ps, GFP_KERNEL);
if (!sk->inurb[u])
return -ENOMEM;

sk->outurb[u] = usb_alloc_urb(sk->n_o_ps, GFP_KERNEL);
if (!sk->outurb[u])
return -ENOMEM;
}

if (init_pipe_urbs(sk, use_packsize, sk->inurb, indata, dev, in_pipe) ||
Expand Down

0 comments on commit a2c6433

Please sign in to comment.