ALSA: usb-audio: Add sanity checks in v2 clock parsers
authorTakashi Iwai <tiwai@suse.de>
Tue, 21 Nov 2017 16:28:06 +0000 (17:28 +0100)
committerBen Hutchings <ben@decadent.org.uk>
Tue, 13 Feb 2018 18:32:20 +0000 (18:32 +0000)
commit50616ee84fb8386f524dcaeca95382e0b3c4e99a
tree27bce2b930c6c7b015623a59834dde92680717c7
parentaceea9eb811ca050b3840086f22b30d32f77ac38
ALSA: usb-audio: Add sanity checks in v2 clock parsers

commit 0a62d6c966956d77397c32836a5bbfe3af786fc1 upstream.

The helper functions to parse and look for the clock source, selector
and multiplier unit may return the descriptor with a too short length
than required, while there is no sanity check in the caller side.
Add some sanity checks in the parsers, at least, to guarantee the
given descriptor size, for avoiding the potential crashes.

Fixes: 79f920fbff56 ("ALSA: usb-audio: parse clock topology of UAC2 devices")
Reported-by: Andrey Konovalov <andreyknvl@google.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
sound/usb/clock.c