aboutsummaryrefslogtreecommitdiffstats
path: root/arch/um/kernel
diff options
context:
space:
mode:
authorJeff Dike <jdike@addtoit.com>2008-02-08 07:22:11 -0500
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2008-02-08 12:22:43 -0500
commitac2a659968f5318a180213f0409c2ea21f072820 (patch)
tree2bebff50071f9f9fef802d2434de951e9c235332 /arch/um/kernel
parent5aaf5f7b871abf00fb2525e7ed2d5938a74ce23c (diff)
uml: fix mm_context memory leak
[ Spotted by Miklos ] Fix a memory leak in init_new_context. The struct page ** buffer allocated for install_special_mapping was never recorded, and thus leaked when the mm_struct was freed. Fix it by saving the pointer in mm_context_t and freeing it in arch_exit_mmap. Signed-off-by: Jeff Dike <jdike@linux.intel.com> Cc: Miklos Szeredi <miklos@szeredi.hu> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'arch/um/kernel')
-rw-r--r--arch/um/kernel/skas/mmu.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/arch/um/kernel/skas/mmu.c b/arch/um/kernel/skas/mmu.c
index 78b3e9f69d57..0cd9a7a05e77 100644
--- a/arch/um/kernel/skas/mmu.c
+++ b/arch/um/kernel/skas/mmu.c
@@ -91,6 +91,8 @@ int init_new_context(struct task_struct *task, struct mm_struct *mm)
91 goto out_free; 91 goto out_free;
92 } 92 }
93 93
94 to_mm->stub_pages = NULL;
95
94 return 0; 96 return 0;
95 97
96 out_free: 98 out_free:
@@ -126,6 +128,7 @@ void arch_dup_mmap(struct mm_struct *oldmm, struct mm_struct *mm)
126 128
127 pages[0] = virt_to_page(&__syscall_stub_start); 129 pages[0] = virt_to_page(&__syscall_stub_start);
128 pages[1] = virt_to_page(mm->context.id.stack); 130 pages[1] = virt_to_page(mm->context.id.stack);
131 mm->context.stub_pages = pages;
129 132
130 /* dup_mmap already holds mmap_sem */ 133 /* dup_mmap already holds mmap_sem */
131 err = install_special_mapping(mm, STUB_START, STUB_END - STUB_START, 134 err = install_special_mapping(mm, STUB_START, STUB_END - STUB_START,
@@ -147,6 +150,8 @@ void arch_exit_mmap(struct mm_struct *mm)
147{ 150{
148 pte_t *pte; 151 pte_t *pte;
149 152
153 if (mm->context.stub_pages != NULL)
154 kfree(mm->context.stub_pages);
150 pte = virt_to_pte(mm, STUB_CODE); 155 pte = virt_to_pte(mm, STUB_CODE);
151 if (pte != NULL) 156 if (pte != NULL)
152 pte_clear(mm, STUB_CODE, pte); 157 pte_clear(mm, STUB_CODE, pte);