]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
swsusp: fix sysfs interface
authorRafael J. Wysocki <rjw@sisk.pl>
Thu, 17 May 2007 05:11:19 +0000 (22:11 -0700)
committerLinus Torvalds <torvalds@woody.linux-foundation.org>
Thu, 17 May 2007 12:23:05 +0000 (05:23 -0700)
The sysfs files /sys/power/disk and /sys/power/state do not work as
documented, since they allow the user to write only a few initial
characters of the input string to trigger the option (eg.  'echo pl >
/sys/power/disk' activates the platform mode of hibernation).  Fix it.

Special thanks to Peter Moulder <Peter.Moulder@infotech.monash.edu.au> for
pointing out the problem.

Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
Acked-by: Pavel Machek <pavel@ucw.cz>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
kernel/power/disk.c
kernel/power/main.c

index b5f0543ed84d38bd44ceb96cb5efe3d0330d15e8..f445b9cd60fbdacad64214fd05ceed7364a82ed7 100644 (file)
@@ -416,7 +416,8 @@ static ssize_t disk_store(struct kset *kset, const char *buf, size_t n)
 
        mutex_lock(&pm_mutex);
        for (i = HIBERNATION_FIRST; i <= HIBERNATION_MAX; i++) {
-               if (!strncmp(buf, hibernation_modes[i], len)) {
+               if (len == strlen(hibernation_modes[i])
+                   && !strncmp(buf, hibernation_modes[i], len)) {
                        mode = i;
                        break;
                }
index b98b80ccf4373d980f080d1e468a5d68244acf36..8812985f30296cd01aab981337fcf90f95b14ff4 100644 (file)
@@ -290,13 +290,13 @@ static ssize_t state_store(struct kset *kset, const char *buf, size_t n)
        len = p ? p - buf : n;
 
        /* First, check if we are requested to hibernate */
-       if (!strncmp(buf, "disk", len)) {
+       if (len == 4 && !strncmp(buf, "disk", len)) {
                error = hibernate();
                return error ? error : n;
        }
 
        for (s = &pm_states[state]; state < PM_SUSPEND_MAX; s++, state++) {
-               if (*s && !strncmp(buf, *s, len))
+               if (*s && len == strlen(*s) && !strncmp(buf, *s, len))
                        break;
        }
        if (state < PM_SUSPEND_MAX && *s)