]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
[um] mconsole: don't open-code memdup_user_nul()
authorAl Viro <viro@zeniv.linux.org.uk>
Sat, 2 Jan 2016 19:53:28 +0000 (14:53 -0500)
committerAl Viro <viro@zeniv.linux.org.uk>
Mon, 4 Jan 2016 15:29:45 +0000 (10:29 -0500)
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
arch/um/drivers/mconsole_kern.c

index 29880c9b324ed33601c8af02340a4765d9d75b3b..b821b13d343a7bb37e1c260aa59ab5387cba195d 100644 (file)
@@ -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;
 }