Commit 34485ee4 authored by Herbert Xu's avatar Herbert Xu Committed by Linus Torvalds

[PATCH] omdisk memory leak fix

Fix a couple of memory leaks in the pmdisk driver.
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent af5bb145
...@@ -795,6 +795,7 @@ static int __init relocate_pagedir(void) ...@@ -795,6 +795,7 @@ static int __init relocate_pagedir(void)
suspend_pagedir_t *new_pagedir, *old_pagedir = pm_pagedir_nosave; suspend_pagedir_t *new_pagedir, *old_pagedir = pm_pagedir_nosave;
void **eaten_memory = NULL; void **eaten_memory = NULL;
void **c = eaten_memory, *m, *f; void **c = eaten_memory, *m, *f;
int err;
pr_debug("pmdisk: Relocating pagedir\n"); pr_debug("pmdisk: Relocating pagedir\n");
...@@ -803,32 +804,31 @@ static int __init relocate_pagedir(void) ...@@ -803,32 +804,31 @@ static int __init relocate_pagedir(void)
return 0; return 0;
} }
err = -ENOMEM;
while ((m = (void *) __get_free_pages(GFP_ATOMIC, pagedir_order))) { while ((m = (void *) __get_free_pages(GFP_ATOMIC, pagedir_order))) {
memset(m, 0, PAGE_SIZE); memset(m, 0, PAGE_SIZE);
if (!does_collide_order(old_pagedir, (unsigned long)m, pagedir_order)) if (!does_collide_order(old_pagedir, (unsigned long)m,
pagedir_order)) {
pm_pagedir_nosave = new_pagedir = m;
copy_pagedir(new_pagedir, old_pagedir);
err = 0;
break; break;
}
eaten_memory = m; eaten_memory = m;
printk( "." ); printk( "." );
*eaten_memory = c; *eaten_memory = c;
c = eaten_memory; c = eaten_memory;
} }
if (!m)
return -ENOMEM;
pm_pagedir_nosave = new_pagedir = m;
copy_pagedir(new_pagedir, old_pagedir);
c = eaten_memory; c = eaten_memory;
while(c) { while(c) {
printk(":"); printk(":");
f = *c; f = c;
c = *c; c = *c;
if (f)
free_pages((unsigned long)f, pagedir_order); free_pages((unsigned long)f, pagedir_order);
} }
printk("|\n"); printk("|\n");
return 0; return err;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment