Skip to content

Commit

Permalink
ALSA: emu10k1: Avoid access to invalid pages when period=1
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
tiwai committed Aug 3, 2012
1 parent c810f90 commit fcfb786
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion sound/pci/emu10k1/memory.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit fcfb786

Please sign in to comment.