ecryptfs: use memdup_user()
authorLi Zefan <lizf@cn.fujitsu.com>
Wed, 8 Apr 2009 07:09:29 +0000 (15:09 +0800)
committerAl Viro <viro@zeniv.linux.org.uk>
Tue, 21 Apr 2009 03:02:51 +0000 (23:02 -0400)
Remove open-coded memdup_user().

Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
fs/ecryptfs/miscdev.c

index a67fea655f49082a25a75342132f7e38c6018995..dda3c58eefc04c28ef058568b278c995ab388477 100644 (file)
@@ -418,18 +418,13 @@ ecryptfs_miscdev_write(struct file *file, const char __user *buf,
 
        if (count == 0)
                goto out;
-       data = kmalloc(count, GFP_KERNEL);
-       if (!data) {
-               printk(KERN_ERR "%s: Out of memory whilst attempting to "
-                      "kmalloc([%zd], GFP_KERNEL)\n", __func__, count);
+
+       data = memdup_user(buf, count);
+       if (IS_ERR(data)) {
+               printk(KERN_ERR "%s: memdup_user returned error [%ld]\n",
+                      __func__, PTR_ERR(data));
                goto out;
        }
-       rc = copy_from_user(data, buf, count);
-       if (rc) {
-               printk(KERN_ERR "%s: copy_from_user returned error [%d]\n",
-                      __func__, rc);
-               goto out_free;
-       }
        sz = count;
        i = 0;
        switch (data[i++]) {