]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
x86/mtrr: Convert to use strncpy_from_user() helper
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Tue, 15 May 2018 18:05:35 +0000 (21:05 +0300)
committerIngo Molnar <mingo@kernel.org>
Wed, 16 May 2018 07:47:23 +0000 (09:47 +0200)
Replace the open coded string fetch from user-space with strncpy_from_user().

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Brian Gerst <brgerst@gmail.com>
Cc: Denys Vlasenko <dvlasenk@redhat.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Luis R. Rodriguez <mcgrof@suse.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Toshi Kani <toshi.kani@hp.com>
Link: http://lkml.kernel.org/r/20180515180535.89703-1-andriy.shevchenko@linux.intel.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
arch/x86/kernel/cpu/mtrr/if.c

index 42b4f2f3b55733189f25efae167b2784aa697478..c610f47373e443ccd4b44441b5a631009e8f43a6 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;