ALSA: vx: Fix possible transfer overflow

The pseudo DMA transfer codes in VX222 and VX-pocket driver have a
slight bug where they check the buffer boundary wrongly, and may
overflow.  Also, the zero sample count might be handled badly for the
playback (although it shouldn't happen in theory).  This patch
addresses these issues.

Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=141541
Signed-off-by: Takashi Iwai <[email protected]>
This commit is contained in:
Takashi Iwai 2017-01-04 12:19:15 +01:00
commit 874e1f6fad
3 changed files with 16 additions and 14 deletions

View file

@ -1048,8 +1048,10 @@ static void vx_pcm_capture_update(struct vx_core *chip, struct snd_pcm_substream
/* ok, let's accelerate! */
int align = pipe->align * 3;
space = (count / align) * align;
vx_pseudo_dma_read(chip, runtime, pipe, space);
count -= space;
if (space > 0) {
vx_pseudo_dma_read(chip, runtime, pipe, space);
count -= space;
}
}
/* read the rest of bytes */
while (count > 0) {