aboutsummaryrefslogtreecommitdiff
path: root/kernel/power/swsusp.c
diff options
context:
space:
mode:
authorRafael J. Wysocki <rjw@sisk.pl>2005-09-27 21:45:43 -0700
committerLinus Torvalds <torvalds@g5.osdl.org>2005-09-28 07:46:41 -0700
commit0f7347c20c410c300be0db4c132945fd02e54110 (patch)
tree8f8a059eaed60c6d4f98a62f7dde447d4a76b9e3 /kernel/power/swsusp.c
parentf65a4d10c8a4eb9f919cf416e5dcd720b7d20f50 (diff)
[PATCH] swsusp: avoid problems if there are too many pages to save
The following patch makes swsusp avoid problems during resume if there are too many pages to save on suspend. It adds a constant that allows us to verify if we are going to save too many pages and implements the check (this is done as early as we can tell that the check will trigger, which is in swsusp_alloc()). Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl> Acked-by: Pavel Machek <pavel@suse.cz> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'kernel/power/swsusp.c')
-rw-r--r--kernel/power/swsusp.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/kernel/power/swsusp.c b/kernel/power/swsusp.c
index 0dfb2494890..acf79ac1cb6 100644
--- a/kernel/power/swsusp.c
+++ b/kernel/power/swsusp.c
@@ -931,6 +931,10 @@ static int swsusp_alloc(void)
if (!enough_swap())
return -ENOSPC;
+ if (MAX_PBES < nr_copy_pages / PBES_PER_PAGE +
+ !!(nr_copy_pages % PBES_PER_PAGE))
+ return -ENOSPC;
+
if (!(pagedir_save = alloc_pagedir(nr_copy_pages))) {
printk(KERN_ERR "suspend: Allocating pagedir failed.\n");
return -ENOMEM;