Skip to content

Commit

Permalink
ALSA: Fix vunmap and free order in snd_free_sgbuf_pages()
Browse files Browse the repository at this point in the history
In snd_free_sgbuf_pags(), vunmap() is called after releasing the SG
pages, and it causes errors on Xen as Xen manages the pages
differently.  Although no significant errors have been reported on
the actual hardware, this order should be fixed other way round,
first vunmap() then free pages.

Cc: Jan Beulich <jbeulich@novell.com>
Cc: <stable@kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
  • Loading branch information
Takashi Iwai committed Mar 18, 2009
1 parent 82f5d57 commit 6af845e
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions sound/core/sgbuf.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ int snd_free_sgbuf_pages(struct snd_dma_buffer *dmab)
if (! sgbuf)
return -EINVAL;

if (dmab->area)
vunmap(dmab->area);
dmab->area = NULL;

tmpb.dev.type = SNDRV_DMA_TYPE_DEV;
tmpb.dev.dev = sgbuf->dev;
for (i = 0; i < sgbuf->pages; i++) {
Expand All @@ -48,9 +52,6 @@ int snd_free_sgbuf_pages(struct snd_dma_buffer *dmab)
tmpb.bytes = (sgbuf->table[i].addr & ~PAGE_MASK) << PAGE_SHIFT;
snd_dma_free_pages(&tmpb);
}
if (dmab->area)
vunmap(dmab->area);
dmab->area = NULL;

kfree(sgbuf->table);
kfree(sgbuf->page_table);
Expand Down

0 comments on commit 6af845e

Please sign in to comment.