]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
swsusp: Fix possible oops in userland interface
authorStefan Seyfried <seife@suse.de>
Sat, 24 Feb 2007 22:06:43 +0000 (23:06 +0100)
committerGreg Kroah-Hartman <gregkh@suse.de>
Fri, 9 Mar 2007 18:50:24 +0000 (10:50 -0800)
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>
kernel/power/user.c

index f7b7a785a5c60a35e133daa036f7b9667ce3d718..38418cda32a6cb49c80a8a97ac08dd203d0dad74 100644 (file)
@@ -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: