Commit 6af845e4eb36fb91b322aaf77ec1cab2220a48ad

Authored by Takashi Iwai
1 parent 82f5d57163

ALSA: Fix vunmap and free order in snd_free_sgbuf_pages()

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>

Showing 1 changed file with 4 additions and 3 deletions Side-by-side Diff

... ... @@ -38,6 +38,10 @@
38 38 if (! sgbuf)
39 39 return -EINVAL;
40 40  
  41 + if (dmab->area)
  42 + vunmap(dmab->area);
  43 + dmab->area = NULL;
  44 +
41 45 tmpb.dev.type = SNDRV_DMA_TYPE_DEV;
42 46 tmpb.dev.dev = sgbuf->dev;
43 47 for (i = 0; i < sgbuf->pages; i++) {
... ... @@ -48,9 +52,6 @@
48 52 tmpb.bytes = (sgbuf->table[i].addr & ~PAGE_MASK) << PAGE_SHIFT;
49 53 snd_dma_free_pages(&tmpb);
50 54 }
51   - if (dmab->area)
52   - vunmap(dmab->area);
53   - dmab->area = NULL;
54 55  
55 56 kfree(sgbuf->table);
56 57 kfree(sgbuf->page_table);