Commit f0ee1a6d authored by Geliang Tang's avatar Geliang Tang Committed by Andy Shevchenko

platform/x86: toshiba_acpi: use memdup_user_nul

Use memdup_user_nul() helper instead of open-coding to simplify the
code.
Signed-off-by: default avatarGeliang Tang <geliangtang@gmail.com>
Signed-off-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
parent 7f363145
...@@ -1502,14 +1502,9 @@ static ssize_t video_proc_write(struct file *file, const char __user *buf, ...@@ -1502,14 +1502,9 @@ static ssize_t video_proc_write(struct file *file, const char __user *buf,
int ret; int ret;
u32 video_out; u32 video_out;
cmd = kmalloc(count + 1, GFP_KERNEL); cmd = memdup_user_nul(buf, count);
if (!cmd) if (IS_ERR(cmd))
return -ENOMEM; return PTR_ERR(cmd);
if (copy_from_user(cmd, buf, count)) {
kfree(cmd);
return -EFAULT;
}
cmd[count] = '\0';
buffer = cmd; buffer = cmd;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment