Messages in this thread Patch in this message |  | | | From | Andy Lutomirski <> | | Subject | [PATCH] x86: Fix memory leak of init_vdso_vars() | | Date | Thu, 21 Jul 2011 10:33:14 -0400 |
| |
From: Zhitong Wang <wzt.wzt@gmail.com>
If init_vdso_vars ran out of memory (not very likely), then it would leak a few pages as well.
Also rename init_vdso_vars to just init_vdso, since initializing vvars is just about the only thing this function doesn't do.
Signed-off-by: Zhitong Wang <zhitong.wangzt@alibaba-inc.com> [Rebased and slightly simplified from the original.] Signed-off-by: Andy Lutomirski <luto@mit.edu> --- arch/x86/vdso/vma.c | 13 +++++++++---- 1 files changed, 9 insertions(+), 4 deletions(-) diff --git a/arch/x86/vdso/vma.c b/arch/x86/vdso/vma.c index c39938d..cabaf0e 100644 --- a/arch/x86/vdso/vma.c +++ b/arch/x86/vdso/vma.c @@ -54,7 +54,7 @@ found: apply_alternatives(alt_data, alt_data + alt_sec->sh_size); } -static int __init init_vdso_vars(void) +static int __init init_vdso(void) { int npages = (vdso_end - vdso_start + PAGE_SIZE - 1) / PAGE_SIZE; int i; @@ -69,19 +69,24 @@ static int __init init_vdso_vars(void) struct page *p; p = alloc_page(GFP_KERNEL); if (!p) - goto oom; + goto oom_free; vdso_pages[i] = p; copy_page(page_address(p), vdso_start + i*PAGE_SIZE); } return 0; - oom: +oom_free: + for(i--; i >= 0; i--) + __free_page(vdso_pages[i]); + __free_page(vdso_pages); + +oom: printk("Cannot allocate vdso\n"); vdso_enabled = 0; return -ENOMEM; } -subsys_initcall(init_vdso_vars); +subsys_initcall(init_vdso); struct linux_binprm; -- 1.7.6
|  |