From: Dan Carpenter Date: Sat, 17 Nov 2012 15:08:57 +0000 (+0300) Subject: sound: oss/sb_audio: cap value in sb201_audio_set_speed() X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=379170a42c84cee5f95fac536a4b5b76843baf90;p=GitHub%2Fmoto-9609%2Fandroid_kernel_motorola_exynos9610.git 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 Signed-off-by: Takashi Iwai --- 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) { sb_devc *devc = audio_devs[dev]->devc; int tmp; - int s = speed * devc->channels; + int s; if (speed > 0) { @@ -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;