Skip to content

Commit

Permalink
[ALSA] sound/drivers/dummy.c: fix negative snd_pcm_format_width() check
Browse files Browse the repository at this point in the history
bps is unsigned, a negative snd_pcm_format_width() return value is not noticed

Signed-off-by: Roel Kluin <[email protected]>
Signed-off-by: Takashi Iwai <[email protected]>
  • Loading branch information
Roel Kluin authored and tiwai committed Apr 24, 2008
1 parent 7943a8a commit 369b240
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions sound/drivers/dummy.c
Original file line number Diff line number Diff line change
Expand Up @@ -230,13 +230,14 @@ static int snd_card_dummy_pcm_prepare(struct snd_pcm_substream *substream)
{
struct snd_pcm_runtime *runtime = substream->runtime;
struct snd_dummy_pcm *dpcm = runtime->private_data;
unsigned int bps;
int bps;

bps = snd_pcm_format_width(runtime->format) * runtime->rate *
runtime->channels / 8;

bps = runtime->rate * runtime->channels;
bps *= snd_pcm_format_width(runtime->format);
bps /= 8;
if (bps <= 0)
return -EINVAL;

dpcm->pcm_bps = bps;
dpcm->pcm_hz = HZ;
dpcm->pcm_buffer_size = snd_pcm_lib_buffer_bytes(substream);
Expand Down

0 comments on commit 369b240

Please sign in to comment.