[PATCH 1/3][Fix] swsusp: remove wrong code from data_free

Rafael J. Wysocki
2005-09-25T18:45:26Z

The following patch removes some wrong code from the data_free() function in
swsusp.

This function could only be called if there's an arror while writing the suspend
image to swap, so it is not triggered easily. However, if triggered, it would
probably corrupt some memory.

Please apply,
Rafael

Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>

Index: linux-2.6.14-rc2-git3/kernel/power/swsusp.c
===================================================================
--- linux-2.6.14-rc2-git3.orig/kernel/power/swsusp.c 2005-09-25 18:45:03.000000000 +0200
+++ linux-2.6.14-rc2-git3/kernel/power/swsusp.c 2005-09-25 18:49:00.000000000 +0200
@@ -402,15 +402,14 @@
static void data_free(void)
{
swp_entry_t entry;
- int i;
+ struct pbe * p;

- for (i = 0; i < nr_copy_pages; i++) {
- entry = (pagedir_nosave + i)->swap_address;
+ for_each_pbe(p, pagedir_nosave) {
+ entry = p->swap_address;
if (entry.val)
swap_free(entry);
else
break;
- (pagedir_nosave + i)->swap_address = (swp_entry_t){0};
}
}