diff options
author | Stefan Seyfried <seife@suse.de> | 2007-02-24 23:06:43 +0100 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2007-03-09 10:50:24 -0800 |
commit | b5f7f3ef64f919fabc5bca0f2f7cc0adfa1ebfc5 (patch) | |
tree | 71656dda6bde10277f5a2d8a8499c9b708a266a8 /kernel | |
parent | 4b5e65dedf3cde7108c9c3d6b6f970eefcd78247 (diff) |
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: Stefan Seyfried <seife@suse.de>
Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
Acked-by: Pavel Machek <pavel@ucw.cz>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/power/user.c | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/kernel/power/user.c b/kernel/power/user.c index f7b7a785a5c..38418cda32a 100644 --- a/kernel/power/user.c +++ b/kernel/power/user.c @@ -292,7 +292,7 @@ static int snapshot_ioctl(struct inode *inode, struct file *filp, break; } - if (pm_ops->prepare) { + if (pm_ops && pm_ops->prepare) { error = pm_ops->prepare(PM_SUSPEND_MEM); if (error) goto OutS3; @@ -311,7 +311,7 @@ static int snapshot_ioctl(struct inode *inode, struct file *filp, device_resume(); } resume_console(); - if (pm_ops->finish) + if (pm_ops && pm_ops->finish) pm_ops->finish(PM_SUSPEND_MEM); OutS3: @@ -322,20 +322,25 @@ static int snapshot_ioctl(struct inode *inode, struct file *filp, switch (arg) { case PMOPS_PREPARE: - if (pm_ops->prepare) { + if (pm_ops && pm_ops->prepare) error = pm_ops->prepare(PM_SUSPEND_DISK); - } + else + error = -ENOSYS; break; case PMOPS_ENTER: kernel_shutdown_prepare(SYSTEM_SUSPEND_DISK); - error = pm_ops->enter(PM_SUSPEND_DISK); + if (pm_ops && pm_ops->enter) + error = pm_ops->enter(PM_SUSPEND_DISK); + else + error = -ENOSYS; break; case PMOPS_FINISH: - if (pm_ops && pm_ops->finish) { + if (pm_ops && pm_ops->finish) pm_ops->finish(PM_SUSPEND_DISK); - } + else + error = -ENOSYS; break; default: |