]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
[ALSA] sound/drivers/dummy.c: fix negative snd_pcm_format_width() check
authorRoel Kluin <12o3l@tiscali.nl>
Wed, 16 Apr 2008 17:30:30 +0000 (19:30 +0200)
committerTakashi Iwai <tiwai@suse.de>
Thu, 24 Apr 2008 10:00:38 +0000 (12:00 +0200)
bps is unsigned, a negative snd_pcm_format_width() return value is not noticed

Signed-off-by: Roel Kluin <12o3l@tiscali.nl>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/drivers/dummy.c

index 83ac4980c5fb294a4906e1faba7b1bd480abf3a4..4e4c69e6cb4c8e850c66c7a2530eab827d793803 100644 (file)
@@ -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);