From: Geliang Tang Date: Sat, 6 May 2017 15:40:19 +0000 (+0800) Subject: platform/x86: toshiba_acpi: use memdup_user_nul X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=f0ee1a6d319df56e49ca8308c5e9b69a9017f69d;p=GitHub%2Fmoto-9609%2Fandroid_kernel_motorola_exynos9610.git 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 Signed-off-by: Andy Shevchenko --- 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;