summaryrefslogtreecommitdiff
path: root/arch/um
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2016-01-02 22:53:28 +0300
committerAl Viro <viro@zeniv.linux.org.uk>2016-01-04 18:29:45 +0300
commit793b796ebfcb3157fe80056a719096a550f0c7d0 (patch)
tree0be940b462012ee2887a3d09dfd60ade3edacddd /arch/um
parent1ceb36285c256347ffa062b7b1b593f801b6697b (diff)
downloadlinux-793b796ebfcb3157fe80056a719096a550f0c7d0.tar.xz
[um] mconsole: don't open-code memdup_user_nul()
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'arch/um')
-rw-r--r--arch/um/drivers/mconsole_kern.c14
1 files changed, 3 insertions, 11 deletions
diff --git a/arch/um/drivers/mconsole_kern.c b/arch/um/drivers/mconsole_kern.c
index 29880c9b324e..b821b13d343a 100644
--- a/arch/um/drivers/mconsole_kern.c
+++ b/arch/um/drivers/mconsole_kern.c
@@ -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;
}