Merge branch 'work.memdup_user' of git://git.kernel.org/pub/scm/linux/kernel/git...
[linux-2.6-block.git] / security / selinux / selinuxfs.c
index 9010a3632d6f79bec2f7a59b78b7d4964df0d401..00eed842c491c3585b68e7b23e2ee63885f02196 100644 (file)
@@ -649,14 +649,12 @@ static ssize_t sel_write_validatetrans(struct file *file,
        if (*ppos != 0)
                goto out;
 
-       rc = -ENOMEM;
-       req = kzalloc(count + 1, GFP_KERNEL);
-       if (!req)
-               goto out;
-
-       rc = -EFAULT;
-       if (copy_from_user(req, buf, count))
+       req = memdup_user_nul(buf, count);
+       if (IS_ERR(req)) {
+               rc = PTR_ERR(req);
+               req = NULL;
                goto out;
+       }
 
        rc = -ENOMEM;
        oldcon = kzalloc(count + 1, GFP_KERNEL);