Skip to content

Commit

Permalink
sound: usb-audio: fix rules check for 32-channel devices
Browse files Browse the repository at this point in the history
When storing the channel numbers used by a format, and if the device
happens to support 32 channels, the code would try to store 1<<32 in
a 32-bit value.

Since no valid format can have zero channels, we can use 1<<(channels-1)
instead of 1<<channels so that all the channel numbers that we test for
fit into 32 bits.

Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
  • Loading branch information
Clemens Ladisch authored and Takashi Iwai committed Mar 2, 2009
1 parent f3990e6 commit eab2b55
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions sound/usb/usbaudio.c
Original file line number Diff line number Diff line change
Expand Up @@ -1783,7 +1783,7 @@ static int check_hw_params_convention(struct snd_usb_substream *subs)
if (rates[f->format] && rates[f->format] != f->rates)
goto __out;
}
channels[f->format] |= (1 << f->channels);
channels[f->format] |= 1 << (f->channels - 1);
rates[f->format] |= f->rates;
/* needs knot? */
if (f->rates & SNDRV_PCM_RATE_KNOT)
Expand All @@ -1810,7 +1810,7 @@ static int check_hw_params_convention(struct snd_usb_substream *subs)
continue;
for (i = 0; i < 32; i++) {
if (f->rates & (1 << i))
channels[i] |= (1 << f->channels);
channels[i] |= 1 << (f->channels - 1);
}
}
cmaster = 0;
Expand Down

0 comments on commit eab2b55

Please sign in to comment.