diff options
Diffstat (limited to 'drivers/platform/x86/thinkpad_acpi.c')
-rw-r--r-- | drivers/platform/x86/thinkpad_acpi.c | 13 |
1 files changed, 3 insertions, 10 deletions
diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c index 25cc86a4a36a..34b8b3fb5444 100644 --- a/drivers/platform/x86/thinkpad_acpi.c +++ b/drivers/platform/x86/thinkpad_acpi.c @@ -913,16 +913,9 @@ static ssize_t dispatch_proc_write(struct file *file, if (count > PAGE_SIZE - 1) return -EINVAL; - kernbuf = kmalloc(count + 1, GFP_KERNEL); - if (!kernbuf) - return -ENOMEM; - - if (copy_from_user(kernbuf, userbuf, count)) { - kfree(kernbuf); - return -EFAULT; - } - - kernbuf[count] = 0; + kernbuf = memdup_user_nul(userbuf, count); + if (IS_ERR(kernbuf)) + return PTR_ERR(kernbuf); ret = ibm->write(kernbuf); if (ret == 0) ret = count; |