Skip to content

Commit

Permalink
[um] mconsole: don't open-code memdup_user_nul()
Browse files Browse the repository at this point in the history
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
  • Loading branch information
Al Viro committed Jan 4, 2016
1 parent 1ceb362 commit 793b796
Showing 1 changed file with 3 additions and 11 deletions.
14 changes: 3 additions & 11 deletions arch/um/drivers/mconsole_kern.c
Original file line number Diff line number Diff line change
Expand Up @@ -748,19 +748,11 @@ static ssize_t mconsole_proc_write(struct file *file,
{
char *buf;

buf = kmalloc(count + 1, GFP_KERNEL);
if (buf == NULL)
return -ENOMEM;

if (copy_from_user(buf, buffer, count)) {
count = -EFAULT;
goto out;
}

buf[count] = '\0';
buf = memdup_user_nul(buffer, count);
if (IS_ERR(buf))
return PTR_ERR(buf);

mconsole_notify(notify_socket, MCONSOLE_USER_NOTIFY, buf, count);
out:
kfree(buf);
return count;
}
Expand Down

0 comments on commit 793b796

Please sign in to comment.