Skip to content

Commit

Permalink
x86, mce: Fix set_trigger() accessor
Browse files Browse the repository at this point in the history
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.

[ Impact: fix oops ]

Signed-off-by: Jan Beulich <jbeulich@novell.com>
Cc: Andi Kleen <andi@firstfloor.org>
LKML-Reference: <4A5F04B7020000780000AB59@vpn.id2.novell.com>
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
  • Loading branch information
Jan Beulich authored and H. Peter Anvin committed Jul 21, 2009
1 parent ebe119c commit e9084ec
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions arch/x86/kernel/cpu/mcheck/mce.c
Original file line number Diff line number Diff line change
Expand Up @@ -1692,17 +1692,15 @@ static ssize_t set_trigger(struct sys_device *s, struct sysdev_attribute *attr,
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,
Expand Down

0 comments on commit e9084ec

Please sign in to comment.