Commit 3090c355 authored by Jaroslav Kysela's avatar Jaroslav Kysela Committed by Linus Torvalds

ALSA CVS update - Jaroslav Kysela <perex@suse.cz>

PCM Midlevel
Fix in snd_pcm_timer_resolution_change() - it no longer oops when
32-bit value overflows.
parent dc79c625
...@@ -32,9 +32,9 @@ ...@@ -32,9 +32,9 @@
*/ */
/* Greatest common divisor */ /* Greatest common divisor */
static int gcd(int a, int b) static unsigned long gcd(unsigned long a, unsigned long b)
{ {
int r; unsigned long r;
if (a < b) { if (a < b) {
r = a; r = a;
a = b; a = b;
...@@ -49,7 +49,7 @@ static int gcd(int a, int b) ...@@ -49,7 +49,7 @@ static int gcd(int a, int b)
void snd_pcm_timer_resolution_change(snd_pcm_substream_t *substream) void snd_pcm_timer_resolution_change(snd_pcm_substream_t *substream)
{ {
unsigned int rate, mult, fsize, l; unsigned long rate, mult, fsize, l;
snd_pcm_runtime_t *runtime = substream->runtime; snd_pcm_runtime_t *runtime = substream->runtime;
mult = 1000000000; mult = 1000000000;
...@@ -67,7 +67,11 @@ void snd_pcm_timer_resolution_change(snd_pcm_substream_t *substream) ...@@ -67,7 +67,11 @@ void snd_pcm_timer_resolution_change(snd_pcm_substream_t *substream)
mult /= 2; mult /= 2;
rate /= 2; rate /= 2;
} }
snd_assert(rate != 0, return); if (rate == 0) {
snd_printk(KERN_ERR "pcm timer resolution out of range (rate = %u, period_size = %lu)\n", runtime->rate, runtime->period_size);
runtime->timer_resolution = -1;
return;
}
runtime->timer_resolution = mult * fsize / rate; runtime->timer_resolution = mult * fsize / rate;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment