diff options
author | Geliang Tang <geliangtang@gmail.com> | 2017-05-06 17:40:19 +0200 |
---|---|---|
committer | Andy Shevchenko <andriy.shevchenko@linux.intel.com> | 2017-05-15 11:06:10 +0200 |
commit | f0ee1a6d319df56e49ca8308c5e9b69a9017f69d (patch) | |
tree | 057a95e082448600b11c6d807a59608cbc9dccb9 /drivers/platform/x86/toshiba_acpi.c | |
parent | platform/x86: ideapad-laptop: Switch touchpad attribute to be RO (diff) | |
download | linux-f0ee1a6d319df56e49ca8308c5e9b69a9017f69d.tar.xz linux-f0ee1a6d319df56e49ca8308c5e9b69a9017f69d.zip |
platform/x86: toshiba_acpi: use memdup_user_nul
Use memdup_user_nul() helper instead of open-coding to simplify the
code.
Signed-off-by: Geliang Tang <geliangtang@gmail.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Diffstat (limited to 'drivers/platform/x86/toshiba_acpi.c')
-rw-r--r-- | drivers/platform/x86/toshiba_acpi.c | 11 |
1 files changed, 3 insertions, 8 deletions
diff --git a/drivers/platform/x86/toshiba_acpi.c b/drivers/platform/x86/toshiba_acpi.c index d0daf75cbed1..88f9f79a7cf6 100644 --- a/drivers/platform/x86/toshiba_acpi.c +++ b/drivers/platform/x86/toshiba_acpi.c @@ -1502,14 +1502,9 @@ static ssize_t video_proc_write(struct file *file, const char __user *buf, int ret; u32 video_out; - cmd = kmalloc(count + 1, GFP_KERNEL); - if (!cmd) - return -ENOMEM; - if (copy_from_user(cmd, buf, count)) { - kfree(cmd); - return -EFAULT; - } - cmd[count] = '\0'; + cmd = memdup_user_nul(buf, count); + if (IS_ERR(cmd)) + return PTR_ERR(cmd); buffer = cmd; |