mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-27 12:57:53 +00:00
ALSA: usb-audio: Stop parsing channels bits when all channels are found.
[ Upstream commita39d51ff1f
] 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:04324ccc75
("ALSA: usb-audio: add channel map support") Message-ID: <20240313081509.9801-1-johan.carlsson@teenage.engineering> Signed-off-by: Takashi Iwai <tiwai@suse.de> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
de4bfe60b0
commit
22cad1b841
1 changed files with 4 additions and 1 deletions
|
@ -300,9 +300,12 @@ static struct snd_pcm_chmap_elem *convert_chmap(int channels, unsigned int bits,
|
||||||
c = 0;
|
c = 0;
|
||||||
|
|
||||||
if (bits) {
|
if (bits) {
|
||||||
for (; bits && *maps; maps++, bits >>= 1)
|
for (; bits && *maps; maps++, bits >>= 1) {
|
||||||
if (bits & 1)
|
if (bits & 1)
|
||||||
chmap->map[c++] = *maps;
|
chmap->map[c++] = *maps;
|
||||||
|
if (c == chmap->channels)
|
||||||
|
break;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
/* If we're missing wChannelConfig, then guess something
|
/* If we're missing wChannelConfig, then guess something
|
||||||
to make sure the channel map is not skipped entirely */
|
to make sure the channel map is not skipped entirely */
|
||||||
|
|
Loading…
Reference in a new issue