X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=arch%2Fi386%2Fkernel%2Fcpu%2Fmtrr%2Fif.c;h=1923e0aed26a896816bc19d4c65257c9d28ae838;hb=f7f1b0f1e2fbadeab12d24236000e778aa9b1ead;hp=0946844217b9cc5879068999789db230a6256074;hpb=e3f6fb6212a7102bdb56ba38fa1e98fe72950475;p=linux-2.6.git diff --git a/arch/i386/kernel/cpu/mtrr/if.c b/arch/i386/kernel/cpu/mtrr/if.c index 094684421..1923e0aed 100644 --- a/arch/i386/kernel/cpu/mtrr/if.c +++ b/arch/i386/kernel/cpu/mtrr/if.c @@ -98,16 +98,20 @@ 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]; + 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)) return -EFAULT; - ptr = line + strlen(line) - 1; - if (*ptr == '\n') + linelen = strlen(line); + ptr = line + linelen - 1; + if (linelen && *ptr == '\n') *ptr = '\0'; if (!strncmp(line, "disable=", 8)) { reg = simple_strtoul(line + 8, &ptr, 0);