summaryrefslogtreecommitdiff
path: root/sound/oss/sb_audio.c
diff options
context:
space:
mode:
authorDan Carpenter <dan.carpenter@oracle.com>2012-08-18 19:55:15 +0400
committerTakashi Iwai <tiwai@suse.de>2012-08-20 12:24:21 +0400
commit94f3ec6b2222eb5c0af0c784f0656ff5b909d870 (patch)
treed67fe0f941e81a1c47d9b49de144f62aeda5c4ee /sound/oss/sb_audio.c
parent5e68fb3cab23b327e9f15803607e697d7eea1966 (diff)
downloadlinux-94f3ec6b2222eb5c0af0c784f0656ff5b909d870.tar.xz
sound: oss/sb_audio: prevent divide by zero bug
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>
Diffstat (limited to 'sound/oss/sb_audio.c')
-rw-r--r--sound/oss/sb_audio.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/sound/oss/sb_audio.c b/sound/oss/sb_audio.c
index 733b014ec7d1..b2b3c014221a 100644
--- a/sound/oss/sb_audio.c
+++ b/sound/oss/sb_audio.c
@@ -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;