]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
ALSA: Fix vunmap and free order in snd_free_sgbuf_pages()
authorTakashi Iwai <tiwai@suse.de>
Tue, 17 Mar 2009 13:00:06 +0000 (14:00 +0100)
committerGreg Kroah-Hartman <gregkh@suse.de>
Mon, 23 Mar 2009 21:59:56 +0000 (14:59 -0700)
commit 6af845e4eb36fb91b322aaf77ec1cab2220a48ad upstream.

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>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
sound/core/sgbuf.c

index cefd228cd2aafb964b61150a7a2d9931459a7fe8..91f16ac937ffd62f1fd38fc18bd45c3b067eb1a6 100644 (file)
@@ -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++) {
@@ -46,9 +50,6 @@ int snd_free_sgbuf_pages(struct snd_dma_buffer *dmab)
                tmpb.bytes = PAGE_SIZE;
                snd_dma_free_pages(&tmpb);
        }
-       if (dmab->area)
-               vunmap(dmab->area);
-       dmab->area = NULL;
 
        kfree(sgbuf->table);
        kfree(sgbuf->page_table);