Skip to content

Commit

Permalink
sound: oss/sb_audio: prevent divide by zero bug
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Dan Carpenter authored and Takashi Iwai committed Aug 20, 2012
1 parent 5e68fb3 commit 94f3ec6
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion sound/oss/sb_audio.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 94f3ec6

Please sign in to comment.