sound: oss/sb_audio: prevent divide by zero bug
authorDan Carpenter <dan.carpenter@oracle.com>
Sat, 18 Aug 2012 15:55:15 +0000 (18:55 +0300)
committerTakashi Iwai <tiwai@suse.de>
Mon, 20 Aug 2012 08:24:21 +0000 (10:24 +0200)
Speed comes from get_user() in audio_ioctl().  We use it to set the "s"
variable before clamping it to valid values so it 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 733b014ec7d1637a50954b46ff64b6bd662241e3..b2b3c014221afd4d6b2079c6a3627f64fcfe9480 100644 (file)
@@ -575,13 +575,15 @@ static int jazz16_audio_set_speed(int dev, int speed)
        if (speed > 0)
        {
                int tmp;
-               int s = speed * devc->channels;
+               int s;
 
                if (speed < 5000)
                        speed = 5000;
                if (speed > 44100)
                        speed = 44100;
 
+               s = speed * devc->channels;
+
                devc->tconst = (256 - ((1000000 + s / 2) / s)) & 0xff;
 
                tmp = 256 - devc->tconst;