Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751600Ab1EUFd0 (ORCPT ); Sat, 21 May 2011 01:33:26 -0400 Received: from mail-qw0-f46.google.com ([209.85.216.46]:39404 "EHLO mail-qw0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750887Ab1EUFdT (ORCPT ); Sat, 21 May 2011 01:33:19 -0400 DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; b=RRf96umtj5NlIxAcV91jzAJAT+SB5dkcNbx7vgXe6XXneSbPbvSDWcHITBVQB/5bt9 tPXTA5J1BPfxO++jdCq1s4ccUMtskBK74/dGZX5Pf7DsTFgfTy1X6aO3HIQlusYIfWjW mSfmWCL64o6gVTlsnL35avcoqrlSmD5sPSvfo= MIME-Version: 1.0 In-Reply-To: References: Date: Sat, 21 May 2011 13:33:17 +0800 Message-ID: Subject: Re: [PATCH] vdso: Fix memory leak of init_vdso_vars(). From: wzt wzt To: ak@linux.intel.com Cc: linux-kernel@vger.kernel.org, x86@kernel.org, mingo@redhat.com, tglx@linutronix.de, hpa@zytor.com Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from base64 to 8bit by mail.home.local id p4L5XUPL020108 Content-Length: 2034 Lines: 58 hi, andi, any comments? On Wed, May 18, 2011 at 3:05 PM, wzt wzt wrote: > Fix memory leak of init_vdso_vars(). > > Signed-off-by: Zhitong Wang > Reviewed-by: Coly Li > > --- >  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 > ????{.n?+???????+%?????ݶ??w??{.n?+????{??G?????{ay?ʇڙ?,j??f???h?????????z_??(?階?ݢj"???m??????G????????????&???~???iO???z??v?^?m???? ????????I?