Re: [PATCH] vdso: Fix memory leak of init_vdso_vars().
From: wzt wzt
Date: Sat May 21 2011 - 01:33:38 EST
hi, andi, any comments?
On Wed, May 18, 2011 at 3:05 PM, wzt wzt <wzt.wzt@xxxxxxxxx> wrote:
> Fix memory leak of init_vdso_vars().
>
> Signed-off-by: Zhitong Wang <zhitong.wangzt@xxxxxxxxxxxxxxx>
> Reviewed-by: Coly Li <bosong.ly@xxxxxxxxxx>
>
> ---
> Âarch/x86/vdso/vma.c | Â 14 ++++++++++----
> Â1 files changed, 10 insertions(+), 4 deletions(-)
>
> diff --git a/arch/x86/vdso/vma.c b/arch/x86/vdso/vma.c
> index 4b5d26f..8d9d652 100644
> --- a/arch/x86/vdso/vma.c
> +++ b/arch/x86/vdso/vma.c
> @@ -44,19 +44,19 @@ static int __init init_vdso_vars(void)
> Â Â Â Âvdso_size = npages << PAGE_SHIFT;
> Â Â Â Âvdso_pages = kmalloc(sizeof(struct page *) * npages, GFP_KERNEL);
> Â Â Â Âif (!vdso_pages)
> - Â Â Â Â Â Â Â goto oom;
> + Â Â Â Â Â Â Â goto oom1;
> Â Â Â Âfor (i = 0; i < npages; i++) {
> Â Â Â Â Â Â Â Âstruct page *p;
> Â Â Â Â Â Â Â Âp = alloc_page(GFP_KERNEL);
> Â Â Â Â Â Â Â Âif (!p)
> - Â Â Â Â Â Â Â Â Â Â Â goto oom;
> + Â Â Â Â Â Â Â Â Â Â Â goto oom2;
> Â Â Â Â Â Â Â Âvdso_pages[i] = p;
> Â Â Â Â Â Â Â Âcopy_page(page_address(p), vdso_start + i*PAGE_SIZE);
> Â Â Â Â}
>
> Â Â Â Âvbase = vmap(vdso_pages, npages, 0, PAGE_KERNEL);
> Â Â Â Âif (!vbase)
> - Â Â Â Â Â Â Â goto oom;
> + Â Â Â Â Â Â Â goto oom2;
>
> Â Â Â Âif (memcmp(vbase, "\177ELF", 4)) {
> Â Â Â Â Â Â Â Âprintk("VDSO: I'm broken; not ELF\n");
> @@ -70,7 +70,13 @@ static int __init init_vdso_vars(void)
> Â Â Â Âvunmap(vbase);
> Â Â Â Âreturn 0;
>
> - oom:
> +oom2:
> + Â Â Â i--;
> + Â Â Â for (; i >= 0; i--)
> + Â Â Â Â Â Â Â __free_page(vdso_pages[i]);
> +oom1:
> + Â Â Â __free_page(vdso_pages);
> +
> Â Â Â Âprintk("Cannot allocate vdso\n");
> Â Â Â Âvdso_enabled = 0;
> Â Â Â Âreturn -ENOMEM;
> --
> 1.7.1
>
¢éì®&Þ~º&¶¬+-±éÝ¥w®Ë±Êâmébìdz¹Þ)í
æèw*jg¬±¨¶Ýj/êäz¹Þà2Þ¨èÚ&¢)ß«a¶Úþø®G«éh®æj:+v¨wèÙ>W±êÞiÛaxPjØm¶ÿÃ-»+ùd_