From: Al Viro Date: Sat, 13 May 2017 22:12:07 +0000 (-0400) Subject: sel_write_validatetrans(): don't open-code memdup_user_nul() X-Git-Tag: v4.13-rc1~151^2~8 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=0b884d25f5212bd0323d179c570962bbf822e330;p=karo-tx-linux.git sel_write_validatetrans(): don't open-code memdup_user_nul() Signed-off-by: Al Viro --- 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);