Skip to content

Commit

Permalink
[PATCH] swsusp: fix nr_copy_pages
Browse files Browse the repository at this point in the history
The following patch moves the recalculation of nr_copy_pages so that the right
number is used in the calculation of the size of memory and swap needed.

It prevents swsusp from attempting to suspend if there is not enough memory
and/or swap (which is unlikely anyway).

Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
Signed-off-by: Pavel Machek <pavel@suse.cz>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
  • Loading branch information
Pavel Machek authored and Linus Torvalds committed Jun 25, 2005
1 parent 2e4d582 commit c61978b
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions kernel/power/swsusp.c
Original file line number Diff line number Diff line change
Expand Up @@ -781,18 +781,18 @@ static int swsusp_alloc(void)
{
int error;

pagedir_nosave = NULL;
nr_copy_pages = calc_nr(nr_copy_pages);

pr_debug("suspend: (pages needed: %d + %d free: %d)\n",
nr_copy_pages, PAGES_FOR_IO, nr_free_pages());

pagedir_nosave = NULL;
if (!enough_free_mem())
return -ENOMEM;

if (!enough_swap())
return -ENOSPC;

nr_copy_pages = calc_nr(nr_copy_pages);

if (!(pagedir_save = alloc_pagedir(nr_copy_pages))) {
printk(KERN_ERR "suspend: Allocating pagedir failed.\n");
return -ENOMEM;
Expand Down

0 comments on commit c61978b

Please sign in to comment.