Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Dan Carpenter and committed by
Takashi Iwai
379170a4 190006f9

+2 -1
+2 -1
sound/oss/sb_audio.c
··· 442 442 { 443 443 sb_devc *devc = audio_devs[dev]->devc; 444 444 int tmp; 445 - int s = speed * devc->channels; 445 + int s; 446 446 447 447 if (speed > 0) 448 448 { ··· 452 452 speed = 44100; 453 453 if (devc->opened & OPEN_READ && speed > 15000) 454 454 speed = 15000; 455 + s = speed * devc->channels; 455 456 devc->tconst = (256 - ((1000000 + s / 2) / s)) & 0xff; 456 457 tmp = 256 - devc->tconst; 457 458 speed = ((1000000 + tmp / 2) / tmp) / devc->channels;