summaryrefslogtreecommitdiffstats
path: root/security/selinux/selinuxfs.c
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2017-05-14 00:12:07 +0200
committerAl Viro <viro@zeniv.linux.org.uk>2017-05-26 05:28:36 +0200
commit0b884d25f5212bd0323d179c570962bbf822e330 (patch)
treecb03f328b079e28c0333c3a099e2e9e6bdc1fb0e /security/selinux/selinuxfs.c
parentLinux 4.12-rc1 (diff)
downloadlinux-0b884d25f5212bd0323d179c570962bbf822e330.tar.xz
linux-0b884d25f5212bd0323d179c570962bbf822e330.zip
sel_write_validatetrans(): don't open-code memdup_user_nul()
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'security/selinux/selinuxfs.c')
-rw-r--r--security/selinux/selinuxfs.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/security/selinux/selinuxfs.c b/security/selinux/selinuxfs.c
index 50062e70140d..0940892de84d 100644
--- a/security/selinux/selinuxfs.c
+++ b/security/selinux/selinuxfs.c
@@ -656,14 +656,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);