From fcfb7866af9a5d0280b7e51dd772990c636b7dec Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Fri, 3 Aug 2012 12:51:21 +0200 Subject: ALSA: emu10k1: Avoid access to invalid pages when period=1 When period=1, the driver tries to allocate a bit bigger buffer than requested by the user due to the irq latency tolerance. This may lead to accesses over the actually allocated pages. This patch adds a check of the page index and assigns the silent page when it's over the given buffer size. Signed-off-by: Takashi Iwai --- sound/pci/emu10k1/memory.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'sound/pci/emu10k1') diff --git a/sound/pci/emu10k1/memory.c b/sound/pci/emu10k1/memory.c index 4f502a2..0a43662 100644 --- a/sound/pci/emu10k1/memory.c +++ b/sound/pci/emu10k1/memory.c @@ -326,7 +326,10 @@ snd_emu10k1_alloc_pages(struct snd_emu10k1 *emu, struct snd_pcm_substream *subst for (page = blk->first_page; page <= blk->last_page; page++, idx++) { unsigned long ofs = idx << PAGE_SHIFT; dma_addr_t addr; - addr = snd_pcm_sgbuf_get_addr(substream, ofs); + if (ofs >= runtime->dma_bytes) + addr = emu->silent_page.addr; + else + addr = snd_pcm_sgbuf_get_addr(substream, ofs); if (! is_valid_page(emu, addr)) { printk(KERN_ERR "emu: failure page = %d\n", idx); mutex_unlock(&hdr->block_mutex); -- cgit v1.1