diff options
author | Jeff Dike <jdike@addtoit.com> | 2008-02-08 04:22:11 -0800 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2008-02-08 09:22:43 -0800 |
commit | ac2a659968f5318a180213f0409c2ea21f072820 (patch) | |
tree | 2bebff50071f9f9fef802d2434de951e9c235332 /arch/um | |
parent | 5aaf5f7b871abf00fb2525e7ed2d5938a74ce23c (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')
-rw-r--r-- | arch/um/include/um_mmu.h | 1 | ||||
-rw-r--r-- | arch/um/kernel/skas/mmu.c | 5 |
2 files changed, 6 insertions, 0 deletions
diff --git a/arch/um/include/um_mmu.h b/arch/um/include/um_mmu.h index 82865fcf687..f575ff91f2a 100644 --- a/arch/um/include/um_mmu.h +++ b/arch/um/include/um_mmu.h @@ -13,6 +13,7 @@ typedef struct mm_context { struct mm_id id; struct uml_ldt ldt; + struct page **stub_pages; } mm_context_t; extern void __switch_mm(struct mm_id * mm_idp); diff --git a/arch/um/kernel/skas/mmu.c b/arch/um/kernel/skas/mmu.c index 78b3e9f69d5..0cd9a7a05e7 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) goto out_free; } + to_mm->stub_pages = NULL; + return 0; out_free: @@ -126,6 +128,7 @@ void arch_dup_mmap(struct mm_struct *oldmm, struct mm_struct *mm) pages[0] = virt_to_page(&__syscall_stub_start); pages[1] = virt_to_page(mm->context.id.stack); + mm->context.stub_pages = pages; /* dup_mmap already holds mmap_sem */ err = install_special_mapping(mm, STUB_START, STUB_END - STUB_START, @@ -147,6 +150,8 @@ void arch_exit_mmap(struct mm_struct *mm) { pte_t *pte; + if (mm->context.stub_pages != NULL) + kfree(mm->context.stub_pages); pte = virt_to_pte(mm, STUB_CODE); if (pte != NULL) pte_clear(mm, STUB_CODE, pte); |