sound: oss/sb_audio: cap value in sb201_audio_set_speed()
authorDan Carpenter <dan.carpenter@oracle.com>
Sat, 17 Nov 2012 15:08:57 +0000 (18:08 +0300)
committerTakashi Iwai <tiwai@suse.de>
Sun, 18 Nov 2012 09:24:49 +0000 (10:24 +0100)
We set "s" before we have capped "speed" so it could be the wrong value.
This could lead to a divide by zero bug.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/oss/sb_audio.c

index b2b3c014221afd4d6b2079c6a3627f64fcfe9480..048439a16000ef08a8ead209285240224ac2683b 100644 (file)
@@ -442,7 +442,7 @@ static int sb201_audio_set_speed(int dev, int speed)
 {
        sb_devc *devc = audio_devs[dev]->devc;
        int tmp;
-       int s = speed * devc->channels;
+       int s;
 
        if (speed > 0)
        {
@@ -452,6 +452,7 @@ static int sb201_audio_set_speed(int dev, int speed)
                        speed = 44100;
                if (devc->opened & OPEN_READ && speed > 15000)
                        speed = 15000;
+               s = speed * devc->channels;
                devc->tconst = (256 - ((1000000 + s / 2) / s)) & 0xff;
                tmp = 256 - devc->tconst;
                speed = ((1000000 + tmp / 2) / tmp) / devc->channels;