
From: Herbert Xu <herbert@gondor.apana.org.au>

This patch fixes the sysfs store functions for pmdisk when the input
contains a trailing newline.


---

 25-akpm/kernel/power/disk.c |    7 ++++++-
 25-akpm/kernel/power/main.c |    7 ++++++-
 2 files changed, 12 insertions(+), 2 deletions(-)

diff -puN kernel/power/disk.c~pmdisk-store-handling-fix kernel/power/disk.c
--- 25/kernel/power/disk.c~pmdisk-store-handling-fix	2004-04-03 02:59:58.515457240 -0800
+++ 25-akpm/kernel/power/disk.c	2004-04-03 02:59:58.519456632 -0800
@@ -285,11 +285,16 @@ static ssize_t disk_store(struct subsyst
 {
 	int error = 0;
 	int i;
+	int len;
+	char *p;
 	u32 mode = 0;
 
+	p = memchr(buf, '\n', n);
+	len = p ? p - buf : n;
+
 	down(&pm_sem);
 	for (i = PM_DISK_FIRMWARE; i < PM_DISK_MAX; i++) {
-		if (!strcmp(buf,pm_disk_modes[i])) {
+		if (!strncmp(buf, pm_disk_modes[i], len)) {
 			mode = i;
 			break;
 		}
diff -puN kernel/power/main.c~pmdisk-store-handling-fix kernel/power/main.c
--- 25/kernel/power/main.c~pmdisk-store-handling-fix	2004-04-03 02:59:58.517456936 -0800
+++ 25-akpm/kernel/power/main.c	2004-04-03 02:59:58.520456480 -0800
@@ -218,10 +218,15 @@ static ssize_t state_store(struct subsys
 {
 	u32 state = PM_SUSPEND_STANDBY;
 	char ** s;
+	char *p;
 	int error;
+	int len;
+
+	p = memchr(buf, '\n', n);
+	len = p ? p - buf : n;
 
 	for (s = &pm_states[state]; *s; s++, state++) {
-		if (!strcmp(buf,*s))
+		if (!strncmp(buf, *s, len))
 			break;
 	}
 	if (*s)

_
