* [PATCH] vdso: Fix memory leak of init_vdso_vars().
@ 2011-05-18 7:05 wzt wzt
2011-05-21 5:33 ` wzt wzt
0 siblings, 1 reply; 2+ messages in thread
From: wzt wzt @ 2011-05-18 7:05 UTC (permalink / raw)
To: linux-kernel; +Cc: x86, ak, mingo, tglx, hpa
[-- Attachment #1: Type: text/plain, Size: 1251 bytes --]
Fix memory leak of init_vdso_vars().
Signed-off-by: Zhitong Wang <zhitong.wangzt@alibaba-inc.com>
Reviewed-by: Coly Li <bosong.ly@taobao.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..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
[-- Attachment #2: 0001-Fix-memory-leak-of-init_vdso_vars.patch --]
[-- Type: text/x-patch, Size: 1255 bytes --]
Fix memory leak of init_vdso_vars().
Signed-off-by: Zhitong Wang <zhitong.wangzt@alibaba-inc.com>
Reviewed-by: Coly Li <bosong.ly@taobao.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..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
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] vdso: Fix memory leak of init_vdso_vars().
2011-05-18 7:05 [PATCH] vdso: Fix memory leak of init_vdso_vars() wzt wzt
@ 2011-05-21 5:33 ` wzt wzt
0 siblings, 0 replies; 2+ messages in thread
From: wzt wzt @ 2011-05-21 5:33 UTC (permalink / raw)
To: ak; +Cc: linux-kernel, x86, mingo, tglx, hpa
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset=UTF-8, Size: 2034 bytes --]
hi, andi, any comments?
On Wed, May 18, 2011 at 3:05 PM, wzt wzt <wzt.wzt@gmail.com> wrote:
> Fix memory leak of init_vdso_vars().
>
> Signed-off-by: Zhitong Wang <zhitong.wangzt@alibaba-inc.com>
> Reviewed-by: Coly Li <bosong.ly@taobao.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..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Ç+·®+%Ëÿ±éݶ\x17¥wÿº{.nÇ+·¥{±þG«éÿ{ayº\x1dÊÚë,j\a¢f£¢·hïêÿêçz_è®\x03(éÝ¢j"ú\x1a¶^[m§ÿÿ¾\a«þG«éÿ¢¸?¨èÚ&£ø§~á¶iOæ¬z·vØ^\x14\x04\x1a¶^[m§ÿÿÃ\fÿ¶ìÿ¢¸?I¥
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2011-05-21 5:33 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-05-18 7:05 [PATCH] vdso: Fix memory leak of init_vdso_vars() wzt wzt
2011-05-21 5:33 ` wzt wzt
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).