Commit b5f7f3ef authored by Stefan Seyfried's avatar Stefan Seyfried Committed by Greg Kroah-Hartman

swsusp: Fix possible oops in userland interface

Fix the Oops occuring when SNAPSHOT_PMOPS or SNAPSHOT_S2RAM ioctl is called on
a system without pm_ops defined (eg. a non-ACPI kernel on x86 PC).
Signed-off-by: default avatarStefan Seyfried <seife@suse.de>
Signed-off-by: default avatarRafael J. Wysocki <rjw@sisk.pl>
Acked-by: default avatarPavel Machek <pavel@ucw.cz>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 4b5e65de
...@@ -292,7 +292,7 @@ static int snapshot_ioctl(struct inode *inode, struct file *filp, ...@@ -292,7 +292,7 @@ static int snapshot_ioctl(struct inode *inode, struct file *filp,
break; break;
} }
if (pm_ops->prepare) { if (pm_ops && pm_ops->prepare) {
error = pm_ops->prepare(PM_SUSPEND_MEM); error = pm_ops->prepare(PM_SUSPEND_MEM);
if (error) if (error)
goto OutS3; goto OutS3;
...@@ -311,7 +311,7 @@ static int snapshot_ioctl(struct inode *inode, struct file *filp, ...@@ -311,7 +311,7 @@ static int snapshot_ioctl(struct inode *inode, struct file *filp,
device_resume(); device_resume();
} }
resume_console(); resume_console();
if (pm_ops->finish) if (pm_ops && pm_ops->finish)
pm_ops->finish(PM_SUSPEND_MEM); pm_ops->finish(PM_SUSPEND_MEM);
OutS3: OutS3:
...@@ -322,20 +322,25 @@ static int snapshot_ioctl(struct inode *inode, struct file *filp, ...@@ -322,20 +322,25 @@ static int snapshot_ioctl(struct inode *inode, struct file *filp,
switch (arg) { switch (arg) {
case PMOPS_PREPARE: case PMOPS_PREPARE:
if (pm_ops->prepare) { if (pm_ops && pm_ops->prepare)
error = pm_ops->prepare(PM_SUSPEND_DISK); error = pm_ops->prepare(PM_SUSPEND_DISK);
} else
error = -ENOSYS;
break; break;
case PMOPS_ENTER: case PMOPS_ENTER:
kernel_shutdown_prepare(SYSTEM_SUSPEND_DISK); kernel_shutdown_prepare(SYSTEM_SUSPEND_DISK);
if (pm_ops && pm_ops->enter)
error = pm_ops->enter(PM_SUSPEND_DISK); error = pm_ops->enter(PM_SUSPEND_DISK);
else
error = -ENOSYS;
break; break;
case PMOPS_FINISH: case PMOPS_FINISH:
if (pm_ops && pm_ops->finish) { if (pm_ops && pm_ops->finish)
pm_ops->finish(PM_SUSPEND_DISK); pm_ops->finish(PM_SUSPEND_DISK);
} else
error = -ENOSYS;
break; break;
default: default:
......
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