Commit 3f66b056 authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] pmdisk: fix strcmp in sysfs store

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

This patch fixes the sysfs store functions for pmdisk when the input
contains a trailing newline.
parent 77abb2f0
......@@ -285,11 +285,16 @@ static ssize_t disk_store(struct subsystem * s, const char * buf, size_t n)
{
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;
}
......
......@@ -218,10 +218,15 @@ static ssize_t state_store(struct subsystem * subsys, const char * buf, size_t n
{
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)
......
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