Commit 18c39be3 authored by Rusty Russell's avatar Rusty Russell Committed by Linus Torvalds

[PATCH] swsusp: do not panic on bad signature with noresume

From:  Pavel Machek <pavel@ucw.cz>

  This patch makes kernel ignore bad signature on suspend device when
  "noresume" is given, and cleans things up a little bit. Please apply,
parent aa6a9a90
...@@ -1084,12 +1084,12 @@ static int __read_suspend_image(struct block_device *bdev, union diskpage *cur, ...@@ -1084,12 +1084,12 @@ static int __read_suspend_image(struct block_device *bdev, union diskpage *cur,
else if (!memcmp("S2",cur->swh.magic.magic,2)) else if (!memcmp("S2",cur->swh.magic.magic,2))
memcpy(cur->swh.magic.magic,"SWAPSPACE2",10); memcpy(cur->swh.magic.magic,"SWAPSPACE2",10);
else { else {
if (noresume)
return -EINVAL;
panic("%sUnable to find suspended-data signature (%.10s - misspelled?\n", panic("%sUnable to find suspended-data signature (%.10s - misspelled?\n",
name_resume, cur->swh.magic.magic); name_resume, cur->swh.magic.magic);
/* We want to panic even with noresume -- we certainly don't want to add
out signature into your ext2 filesystem ;-) */
} }
if(noresume) { if (noresume) {
/* We don't do a sanity check here: we want to restore the swap /* We don't do a sanity check here: we want to restore the swap
whatever version of kernel made the suspend image; whatever version of kernel made the suspend image;
We need to write swap, but swap is *not* enabled so We need to write swap, but swap is *not* enabled so
...@@ -1207,11 +1207,11 @@ void software_resume(void) ...@@ -1207,11 +1207,11 @@ void software_resume(void)
/* We enable the possibility of machine suspend */ /* We enable the possibility of machine suspend */
software_suspend_enabled = 1; software_suspend_enabled = 1;
#endif #endif
if(!resume_status) if (!resume_status)
return; return;
printk( "%s", name_resume ); printk( "%s", name_resume );
if(resume_status == NORESUME) { if (resume_status == NORESUME) {
if(resume_file[0]) if(resume_file[0])
read_suspend_image(resume_file, 1); read_suspend_image(resume_file, 1);
printk( "disabled\n" ); printk( "disabled\n" );
...@@ -1240,7 +1240,7 @@ void software_resume(void) ...@@ -1240,7 +1240,7 @@ void software_resume(void)
static int __init resume_setup(char *str) static int __init resume_setup(char *str)
{ {
if(resume_status) if (resume_status == NORESUME)
return 1; return 1;
strncpy( resume_file, str, 255 ); strncpy( resume_file, str, 255 );
...@@ -1249,16 +1249,13 @@ static int __init resume_setup(char *str) ...@@ -1249,16 +1249,13 @@ static int __init resume_setup(char *str)
return 1; return 1;
} }
static int __init software_noresume(char *str) static int __init noresume_setup(char *str)
{ {
if(!resume_status)
printk(KERN_WARNING "noresume option lacks a resume= option\n");
resume_status = NORESUME; resume_status = NORESUME;
return 1; return 1;
} }
__setup("noresume", software_noresume); __setup("noresume", noresume_setup);
__setup("resume=", resume_setup); __setup("resume=", resume_setup);
EXPORT_SYMBOL(software_suspend); EXPORT_SYMBOL(software_suspend);
......
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