Skip to content

Commit

Permalink
sound: oss/sb_audio: cap value in sb201_audio_set_speed()
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Dan Carpenter authored and Takashi Iwai committed Nov 18, 2012
1 parent 190006f commit 379170a
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion sound/oss/sb_audio.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -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;
Expand Down

0 comments on commit 379170a

Please sign in to comment.