ALSA: ctxfi - Fix possible buffer pointer overrun
authorTakashi Iwai <tiwai@suse.de>
Mon, 8 Jun 2009 13:07:46 +0000 (15:07 +0200)
committerTakashi Iwai <tiwai@suse.de>
Mon, 8 Jun 2009 13:07:46 +0000 (15:07 +0200)
Fix possible buffer pointer overruns.  Back to zero when it's equal
or over the buffer size.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/pci/ctxfi/ctpcm.c

index a0bd31c6090d6e727ce9caeb1336b64026b052dd..870fa170f046ab632abe9cd2ee40562f87b69b43 100644 (file)
@@ -243,6 +243,8 @@ ct_pcm_playback_pointer(struct snd_pcm_substream *substream)
        /* Read out playback position */
        position = atc->pcm_playback_position(atc, apcm);
        position = bytes_to_frames(runtime, position);
+       if (position >= runtime->buffer_size)
+               position = 0;
        return position;
 }
 
@@ -343,6 +345,8 @@ ct_pcm_capture_pointer(struct snd_pcm_substream *substream)
        /* Read out playback position */
        position = atc->pcm_capture_position(atc, apcm);
        position = bytes_to_frames(runtime, position);
+       if (position >= runtime->buffer_size)
+               position = 0;
        return position;
 }