[ALSA] pcm - Fix zero-division in 32bit compat layer
PCM Midlevel
Fixed zero-division bug in PCM 32bit compat layer.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
diff --git a/sound/core/pcm_compat.c b/sound/core/pcm_compat.c
index eef94a1..4b6307d 100644
--- a/sound/core/pcm_compat.c
+++ b/sound/core/pcm_compat.c
@@ -144,7 +144,7 @@
err = snd_pcm_sw_params(substream, ¶ms);
if (err < 0)
return err;
- if (put_user(boundary, &src->boundary))
+ if (boundary && put_user(boundary, &src->boundary))
return -EFAULT;
return err;
}
@@ -252,8 +252,11 @@
goto error;
}
- if (! refine)
- runtime->boundary = recalculate_boundary(runtime);
+ if (! refine) {
+ unsigned int new_boundary = recalculate_boundary(runtime);
+ if (new_boundary)
+ runtime->boundary = new_boundary;
+ }
error:
kfree(data);
return err;
@@ -408,6 +411,8 @@
status = runtime->status;
control = runtime->control;
boundary = recalculate_boundary(runtime);
+ if (! boundary)
+ boundary = 0x7fffffff;
snd_pcm_stream_lock_irq(substream);
/* FIXME: we should consider the boundary for the sync from app */
if (!(sflags & SNDRV_PCM_SYNC_PTR_APPL))