Skip to content

Commit f0ee1a6

Browse files
geliangtangandy-shev
authored andcommitted
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>
1 parent 7f36314 commit f0ee1a6

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

drivers/platform/x86/toshiba_acpi.c

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1502,14 +1502,9 @@ static ssize_t video_proc_write(struct file *file, const char __user *buf,
15021502
int ret;
15031503
u32 video_out;
15041504

1505-
cmd = kmalloc(count + 1, GFP_KERNEL);
1506-
if (!cmd)
1507-
return -ENOMEM;
1508-
if (copy_from_user(cmd, buf, count)) {
1509-
kfree(cmd);
1510-
return -EFAULT;
1511-
}
1512-
cmd[count] = '\0';
1505+
cmd = memdup_user_nul(buf, count);
1506+
if (IS_ERR(cmd))
1507+
return PTR_ERR(cmd);
15131508

15141509
buffer = cmd;
15151510

0 commit comments

Comments
 (0)