Commit 8a8d56b2a2f9aa423c3d8b6b1e2792c0492059ed

Authored by Jesper Juhl
Committed by Takashi Iwai
1 parent 89e1e66d6b

ALSA: usb - driver neglects kmalloc return value check and may deref NULL

sound/usb/pcm.c::snd_usb_pcm_check_knot() fails to check the return value
from kmalloc() and may end up dereferencing a null pointer.
The patch below (compile tested only) should take care of that little
problem.

Signed-off-by: Jesper Juhl <jj@chaosbits.net>
Signed-off-by: Takashi Iwai <tiwai@suse.de>

Showing 1 changed file with 3 additions and 1 deletions Side-by-side Diff

... ... @@ -676,8 +676,10 @@
676 676 if (!needs_knot)
677 677 return 0;
678 678  
679   - subs->rate_list.count = count;
680 679 subs->rate_list.list = kmalloc(sizeof(int) * count, GFP_KERNEL);
  680 + if (!subs->rate_list.list)
  681 + return -ENOMEM;
  682 + subs->rate_list.count = count;
681 683 subs->rate_list.mask = 0;
682 684 count = 0;
683 685 list_for_each_entry(fp, &subs->fmt_list, list) {