aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/kernel/cpu/mtrr/if.c
diff options
context:
space:
mode:
authorRussell King <rmk+kernel@arm.linux.org.uk>2009-10-12 14:38:08 +0100
committerRussell King <rmk+kernel@arm.linux.org.uk>2009-10-12 14:38:08 +0100
commitedc72786d208e77db94f84dcb0d166c0d23d82f7 (patch)
tree6fd32770f9cb2f1a888775514294d60aecba5245 /arch/x86/kernel/cpu/mtrr/if.c
parentARM: Add kmap_atomic type debugging (diff)
parent[ARM] pxa: workaround errata #37 by not using half turbo switching (diff)
downloadlinux-dev-edc72786d208e77db94f84dcb0d166c0d23d82f7.tar.xz
linux-dev-edc72786d208e77db94f84dcb0d166c0d23d82f7.zip
Merge branch 'fix' of git://git.kernel.org/pub/scm/linux/kernel/git/ycmiao/pxa-linux-2.6
Diffstat (limited to 'arch/x86/kernel/cpu/mtrr/if.c')
-rw-r--r--arch/x86/kernel/cpu/mtrr/if.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/arch/x86/kernel/cpu/mtrr/if.c b/arch/x86/kernel/cpu/mtrr/if.c
index f04e72527604..3c1b12d461d1 100644
--- a/arch/x86/kernel/cpu/mtrr/if.c
+++ b/arch/x86/kernel/cpu/mtrr/if.c
@@ -96,17 +96,24 @@ mtrr_write(struct file *file, const char __user *buf, size_t len, loff_t * ppos)
unsigned long long base, size;
char *ptr;
char line[LINE_SIZE];
+ int length;
size_t linelen;
if (!capable(CAP_SYS_ADMIN))
return -EPERM;
- if (!len)
- return -EINVAL;
memset(line, 0, LINE_SIZE);
- if (len > LINE_SIZE)
- len = LINE_SIZE;
- if (copy_from_user(line, buf, len - 1))
+
+ length = len;
+ length--;
+
+ if (length > LINE_SIZE - 1)
+ length = LINE_SIZE - 1;
+
+ if (length < 0)
+ return -EINVAL;
+
+ if (copy_from_user(line, buf, length))
return -EFAULT;
linelen = strlen(line);