aboutsummaryrefslogtreecommitdiffstats
path: root/sound/pci/emu10k1
diff options
context:
space:
mode:
authorJaroslav Kysela <perex@perex.cz>2008-06-17 10:20:13 -0400
committerJaroslav Kysela <perex@perex.cz>2008-06-17 10:20:13 -0400
commit9f515b6898d0f2c1b9eb34ae9986794045f34e2b (patch)
tree85bb527513fbbcc62d8d3fa5d6762f906df3787f /sound/pci/emu10k1
parent6719292af5513da52aa876d0e7ac4367a0851845 (diff)
ALSA: emu10k1 - fix possible memory leak in memory allocation routines
The leak was introduced in "[ALSA] emu10k1 - simplify page allocation for synth" commit. Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Diffstat (limited to 'sound/pci/emu10k1')
-rw-r--r--sound/pci/emu10k1/memory.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/sound/pci/emu10k1/memory.c b/sound/pci/emu10k1/memory.c
index 42943b4fcb7b..759e29f89478 100644
--- a/sound/pci/emu10k1/memory.c
+++ b/sound/pci/emu10k1/memory.c
@@ -464,11 +464,17 @@ static int synth_alloc_pages(struct snd_emu10k1 *emu, struct snd_emu10k1_memblk
464 /* first try to allocate from <4GB zone */ 464 /* first try to allocate from <4GB zone */
465 struct page *p = alloc_page(GFP_KERNEL | GFP_DMA32 | 465 struct page *p = alloc_page(GFP_KERNEL | GFP_DMA32 |
466 __GFP_NOWARN); 466 __GFP_NOWARN);
467 if (!p || (page_to_pfn(p) & ~(emu->dma_mask >> PAGE_SHIFT))) 467 if (!p || (page_to_pfn(p) & ~(emu->dma_mask >> PAGE_SHIFT))) {
468 /* try to allocate from <16MB zone */ 468 /* try to allocate from <16MB zone */
469 p = alloc_page(GFP_ATOMIC | GFP_DMA | 469 struct page *p1 =
470 alloc_page(GFP_ATOMIC | GFP_DMA |
470 __GFP_NORETRY | /* no OOM-killer */ 471 __GFP_NORETRY | /* no OOM-killer */
471 __GFP_NOWARN); 472 __GFP_NOWARN);
473 /* free page outside dma_mask range */
474 if (p)
475 free_page((unsigned long)page_address(p));
476 p = p1;
477 }
472 if (!p) { 478 if (!p) {
473 __synth_free_pages(emu, first_page, page - 1); 479 __synth_free_pages(emu, first_page, page - 1);
474 return -ENOMEM; 480 return -ENOMEM;