diff options
author | Dan Carpenter <dan.carpenter@oracle.com> | 2012-11-17 10:08:57 -0500 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2012-11-18 04:24:49 -0500 |
commit | 379170a42c84cee5f95fac536a4b5b76843baf90 (patch) | |
tree | 711883cc5769c9d9cfccfcf211bc6a9b29d1de41 /sound/oss/sb_audio.c | |
parent | 190006f9d6594ee9ef4775ec09edda7df76fc8f1 (diff) |
sound: oss/sb_audio: cap value in sb201_audio_set_speed()
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>
Diffstat (limited to 'sound/oss/sb_audio.c')
-rw-r--r-- | sound/oss/sb_audio.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/sound/oss/sb_audio.c b/sound/oss/sb_audio.c index b2b3c014221a..048439a16000 100644 --- a/sound/oss/sb_audio.c +++ b/sound/oss/sb_audio.c | |||
@@ -442,7 +442,7 @@ static int sb201_audio_set_speed(int dev, int speed) | |||
442 | { | 442 | { |
443 | sb_devc *devc = audio_devs[dev]->devc; | 443 | sb_devc *devc = audio_devs[dev]->devc; |
444 | int tmp; | 444 | int tmp; |
445 | int s = speed * devc->channels; | 445 | int s; |
446 | 446 | ||
447 | if (speed > 0) | 447 | if (speed > 0) |
448 | { | 448 | { |
@@ -452,6 +452,7 @@ static int sb201_audio_set_speed(int dev, int speed) | |||
452 | speed = 44100; | 452 | speed = 44100; |
453 | if (devc->opened & OPEN_READ && speed > 15000) | 453 | if (devc->opened & OPEN_READ && speed > 15000) |
454 | speed = 15000; | 454 | speed = 15000; |
455 | s = speed * devc->channels; | ||
455 | devc->tconst = (256 - ((1000000 + s / 2) / s)) & 0xff; | 456 | devc->tconst = (256 - ((1000000 + s / 2) / s)) & 0xff; |
456 | tmp = 256 - devc->tconst; | 457 | tmp = 256 - devc->tconst; |
457 | speed = ((1000000 + tmp / 2) / tmp) / devc->channels; | 458 | speed = ((1000000 + tmp / 2) / tmp) / devc->channels; |