[PATCH] x86: fix MCE's set_trigger() accessor

From: Jan Beulich
Date: Thu Jul 16 2009 - 04:45:22 EST


Impact: fix oops

Fix the condition checking the result of strchr() (which previously
could result in an oops), and make the function return the number of
bytes actively used.

Signed-off-by: Jan Beulich <jbeulich@xxxxxxxxxx>

---
arch/x86/kernel/cpu/mcheck/mce.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)

--- linux-2.6.31-rc3/arch/x86/kernel/cpu/mcheck/mce.c 2009-07-16 10:01:19.000000000 +0200
+++ 2.6.31-rc3-x86-mce-set-trigger/arch/x86/kernel/cpu/mcheck/mce.c 2009-07-16 00:00:00.000000000 +0200
@@ -1692,17 +1692,15 @@ static ssize_t set_trigger(struct sys_de
const char *buf, size_t siz)
{
char *p;
- int len;

strncpy(mce_helper, buf, sizeof(mce_helper));
mce_helper[sizeof(mce_helper)-1] = 0;
- len = strlen(mce_helper);
p = strchr(mce_helper, '\n');

- if (*p)
+ if (p)
*p = 0;

- return len;
+ return strlen(mce_helper) + !!p;
}

static ssize_t set_ignore_ce(struct sys_device *s,



--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/