Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

ALSA: usb-audio: Stop parsing channels bits when all channels are found.

If a usb audio device sets more bits than the amount of channels
it could write outside of the map array.

Signed-off-by: Johan Carlsson <johan.carlsson@teenage.engineering>
Fixes: 04324ccc75f9 ("ALSA: usb-audio: add channel map support")
Message-ID: <20240313081509.9801-1-johan.carlsson@teenage.engineering>
Signed-off-by: Takashi Iwai <tiwai@suse.de>

authored by

Johan Carlsson and committed by
Takashi Iwai
a39d51ff 526d0283

+4 -1
+4 -1
sound/usb/stream.c
··· 300 300 c = 0; 301 301 302 302 if (bits) { 303 - for (; bits && *maps; maps++, bits >>= 1) 303 + for (; bits && *maps; maps++, bits >>= 1) { 304 304 if (bits & 1) 305 305 chmap->map[c++] = *maps; 306 + if (c == chmap->channels) 307 + break; 308 + } 306 309 } else { 307 310 /* If we're missing wChannelConfig, then guess something 308 311 to make sure the channel map is not skipped entirely */