]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
[ALSA] pcm - Fix zero-division in 32bit compat layer
authorTakashi Iwai <tiwai@suse.de>
Thu, 25 Aug 2005 17:51:47 +0000 (19:51 +0200)
committerJaroslav Kysela <perex@suse.cz>
Tue, 30 Aug 2005 06:47:40 +0000 (08:47 +0200)
PCM Midlevel
Fixed zero-division bug in PCM 32bit compat layer.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/core/pcm_compat.c

index eef94a15f50a0500812bb93d35f62f930ebf5fcb..4b6307df846d4c1f55c0c3b66913992061b6e128 100644 (file)
@@ -144,7 +144,7 @@ static int snd_pcm_ioctl_sw_params_compat(snd_pcm_substream_t *substream,
        err = snd_pcm_sw_params(substream, &params);
        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 @@ static int snd_pcm_ioctl_hw_params_compat(snd_pcm_substream_t *substream,
                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 @@ static int snd_pcm_ioctl_sync_ptr_compat(snd_pcm_substream_t *substream,
        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))