x86/mtrr: Convert to use strncpy_from_user() helper
[linux-2.6-microblaze.git] / arch / x86 / kernel / cpu / mtrr / if.c
index 42b4f2f..c610f47 100644 (file)
@@ -106,17 +106,9 @@ mtrr_write(struct file *file, const char __user *buf, size_t len, loff_t * ppos)
 
        memset(line, 0, LINE_SIZE);
 
-       length = len;
-       length--;
-
-       if (length > LINE_SIZE - 1)
-               length = LINE_SIZE - 1;
-
+       length = strncpy_from_user(line, buf, LINE_SIZE - 1);
        if (length < 0)
-               return -EINVAL;
-
-       if (copy_from_user(line, buf, length))
-               return -EFAULT;
+               return length;
 
        linelen = strlen(line);
        ptr = line + linelen - 1;