From: wzt <wzt.wzt@gmail.com>
To: mingo@redhat.com
Cc: linux-kernel@vger.kernel.org, x86@kernel.org, ak@linux.intel.com,
tglx@linutronix.de, hpa@zytor.com
Subject: [PATCH] x86: Fix memory leak of init_vdso_vars()
Date: Tue, 5 Jul 2011 14:21:48 +0800 [thread overview]
Message-ID: <20110705062148.GA6056@program> (raw)
Fix memory leak of init_vdso_vars().
Signed-off-by: Zhitong Wang <zhitong.wangzt@alibaba-inc.com>
---
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..c6b0308 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]);
+ __free_page(vdso_pages);
+
+oom1:
printk("Cannot allocate vdso\n");
vdso_enabled = 0;
return -ENOMEM;
--
1.7.4.1
next reply other threads:[~2011-07-05 6:21 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-07-05 6:21 wzt [this message]
2011-07-07 13:14 ` [PATCH] x86: Fix memory leak of init_vdso_vars() Michal Hocko
2011-07-07 18:33 ` Andi Kleen
2011-07-11 3:23 ` wzt wzt
2011-07-11 10:04 ` Ingo Molnar
2011-07-21 14:33 ` Andy Lutomirski
2011-07-21 17:08 ` Andi Kleen
2011-07-21 17:26 ` Andrew Lutomirski
2011-07-21 18:38 ` Ingo Molnar
2011-07-21 19:39 ` Andrew Lutomirski
2011-07-21 19:43 ` Ingo Molnar
2011-07-21 19:47 ` [PATCH] x86-64: Do not allocate memory for the vDSO Andy Lutomirski
2011-07-21 20:52 ` [tip:x86/vdso] x86-64, vdso: " tip-bot for Andy Lutomirski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20110705062148.GA6056@program \
--to=wzt.wzt@gmail.com \
--cc=ak@linux.intel.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=tglx@linutronix.de \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox