diff options
author | Takashi Iwai <tiwai@suse.de> | 2016-03-15 15:20:58 +0100 |
---|---|---|
committer | Ben Hutchings <ben@decadent.org.uk> | 2016-05-01 00:05:18 +0200 |
commit | c0e9921c951610c287650bf70495d7ccac8bee7f (patch) | |
tree | 358bdbd27dbb06257c9772c7f318839e34249546 /sound | |
parent | 8e5c3482b5c7bcbd7df6b10ddb6d7bcc578f3553 (diff) |
ALSA: usb-audio: Add sanity checks for endpoint accesses
commit 447d6275f0c21f6cc97a88b3a0c601436a4cdf2a 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=971125
Signed-off-by: Takashi Iwai <tiwai@suse.de>
[bwh: Backported to 3.2: drop changes to code we don't have]
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Diffstat (limited to 'sound')
-rw-r--r-- | sound/usb/clock.c | 2 | ||||
-rw-r--r-- | sound/usb/pcm.c | 2 |
2 files changed, 4 insertions, 0 deletions
diff --git a/sound/usb/clock.c b/sound/usb/clock.c index 5e634a2eb282..4c01f877227c 100644 --- a/sound/usb/clock.c +++ b/sound/usb/clock.c @@ -211,6 +211,8 @@ static int set_sample_rate_v1(struct snd_usb_audio *chip, int iface, unsigned char data[3]; int err, crate; + if (get_iface_desc(alts)->bNumEndpoints < 1) + return -EINVAL; ep = get_endpoint(alts, 0)->bEndpointAddress; /* if endpoint doesn't have sampling rate control, bail out */ diff --git a/sound/usb/pcm.c b/sound/usb/pcm.c index 983e0719f923..d5cdf1fc051a 100644 --- a/sound/usb/pcm.c +++ b/sound/usb/pcm.c @@ -148,6 +148,8 @@ static int init_pitch_v1(struct snd_usb_audio *chip, int iface, unsigned char data[1]; int err; + if (get_iface_desc(alts)->bNumEndpoints < 1) + return -EINVAL; ep = get_endpoint(alts, 0)->bEndpointAddress; data[0] = 1; |