Skip to content

Commit

Permalink
ALSA: usb - driver neglects kmalloc return value check and may deref …
Browse files Browse the repository at this point in the history
…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>
  • Loading branch information
Jesper Juhl authored and Takashi Iwai committed Nov 1, 2010
1 parent 89e1e66 commit 8a8d56b
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion sound/usb/pcm.c
Original file line number Diff line number Diff line change
Expand Up @@ -676,8 +676,10 @@ static int snd_usb_pcm_check_knot(struct snd_pcm_runtime *runtime,
if (!needs_knot)
return 0;

subs->rate_list.count = count;
subs->rate_list.list = kmalloc(sizeof(int) * count, GFP_KERNEL);
if (!subs->rate_list.list)
return -ENOMEM;
subs->rate_list.count = count;
subs->rate_list.mask = 0;
count = 0;
list_for_each_entry(fp, &subs->fmt_list, list) {
Expand Down

0 comments on commit 8a8d56b

Please sign in to comment.