aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>2018-05-15 14:05:35 -0400
committerIngo Molnar <mingo@kernel.org>2018-05-16 03:47:23 -0400
commit7f8ec5a4f01aa7d03e94a3d99d7b5f9c02d7fe5a (patch)
tree02ae01aa53fd0b04755c1199d5ea0b42feca81cc
parent13a4db9d75ec5dbca4bd6229e149e061ef7a6bf0 (diff)
x86/mtrr: Convert to use strncpy_from_user() helper
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>
-rw-r--r--arch/x86/kernel/cpu/mtrr/if.c12
1 files changed, 2 insertions, 10 deletions
diff --git a/arch/x86/kernel/cpu/mtrr/if.c b/arch/x86/kernel/cpu/mtrr/if.c
index 42b4f2f3b557..c610f47373e4 100644
--- a/arch/x86/kernel/cpu/mtrr/if.c
+++ b/arch/x86/kernel/cpu/mtrr/if.c
@@ -106,17 +106,9 @@ mtrr_write(struct file *file, const char __user *buf, size_t len, loff_t * ppos)
106 106
107 memset(line, 0, LINE_SIZE); 107 memset(line, 0, LINE_SIZE);
108 108
109 length = len; 109 length = strncpy_from_user(line, buf, LINE_SIZE - 1);
110 length--;
111
112 if (length > LINE_SIZE - 1)
113 length = LINE_SIZE - 1;
114
115 if (length < 0) 110 if (length < 0)
116 return -EINVAL; 111 return length;
117
118 if (copy_from_user(line, buf, length))
119 return -EFAULT;
120 112
121 linelen = strlen(line); 113 linelen = strlen(line);
122 ptr = line + linelen - 1; 114 ptr = line + linelen - 1;