Skip to content

Commit

Permalink
ALSA: usb-audio: Fix NULL dereference in create_fixed_stream_quirk()
Browse files Browse the repository at this point in the history
create_fixed_stream_quirk() may cause a NULL-pointer dereference by
accessing the non-existing endpoint when a USB device with a malformed
USB descriptor is used.

This patch avoids it simply by adding a sanity check of bNumEndpoints
before the accesses.

Bugzilla: https://bugzilla.suse.com/show_bug.cgi?id=971125
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
  • Loading branch information
tiwai committed Mar 16, 2016
1 parent b62232d commit 0f886ca
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions sound/usb/quirks.c
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,12 @@ static int create_fixed_stream_quirk(struct snd_usb_audio *chip,
}
alts = &iface->altsetting[fp->altset_idx];
altsd = get_iface_desc(alts);
if (altsd->bNumEndpoints < 1) {
kfree(fp);
kfree(rate_table);
return -EINVAL;
}

fp->protocol = altsd->bInterfaceProtocol;

if (fp->datainterval == 0)
Expand Down

0 comments on commit 0f886ca

Please sign in to comment.