Commit c0e9921c authored by Takashi Iwai's avatar Takashi Iwai Committed by Ben Hutchings

ALSA: usb-audio: Add sanity checks for endpoint accesses

commit 447d6275 upstream.

Add some sanity check codes before actually accessing the endpoint via
get_endpoint() in order to avoid the invalid access through a
malformed USB descriptor.  Mostly just checking bNumEndpoints, but in
one place (snd_microii_spdif_default_get()), the validity of iface and
altsetting index is checked as well.

Bugzilla: https://bugzilla.suse.com/show_bug.cgi?id=971125Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
[bwh: Backported to 3.2: drop changes to code we don't have]
Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
parent 8e5c3482
...@@ -211,6 +211,8 @@ static int set_sample_rate_v1(struct snd_usb_audio *chip, int iface, ...@@ -211,6 +211,8 @@ static int set_sample_rate_v1(struct snd_usb_audio *chip, int iface,
unsigned char data[3]; unsigned char data[3];
int err, crate; int err, crate;
if (get_iface_desc(alts)->bNumEndpoints < 1)
return -EINVAL;
ep = get_endpoint(alts, 0)->bEndpointAddress; ep = get_endpoint(alts, 0)->bEndpointAddress;
/* if endpoint doesn't have sampling rate control, bail out */ /* if endpoint doesn't have sampling rate control, bail out */
......
...@@ -148,6 +148,8 @@ static int init_pitch_v1(struct snd_usb_audio *chip, int iface, ...@@ -148,6 +148,8 @@ static int init_pitch_v1(struct snd_usb_audio *chip, int iface,
unsigned char data[1]; unsigned char data[1];
int err; int err;
if (get_iface_desc(alts)->bNumEndpoints < 1)
return -EINVAL;
ep = get_endpoint(alts, 0)->bEndpointAddress; ep = get_endpoint(alts, 0)->bEndpointAddress;
data[0] = 1; data[0] = 1;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment