summaryrefslogtreecommitdiffstats
path: root/security/smack
diff options
context:
space:
mode:
authorMarkus Elfring <elfring@users.sourceforge.net>2016-08-21 20:17:36 +0200
committerCasey Schaufler <casey@schaufler-ca.com>2016-08-23 18:58:21 +0200
commit63e24c497158c066583b9c06378d89ace694265a (patch)
treea9ae72852efa1c4ed56968e501f226fd672e0308 /security/smack
parentLinux 4.8-rc1 (diff)
downloadlinux-63e24c497158c066583b9c06378d89ace694265a.tar.xz
linux-63e24c497158c066583b9c06378d89ace694265a.zip
Smack: Use memdup_user() rather than duplicating its implementation
Reuse existing functionality from memdup_user() instead of keeping duplicate source code. This issue was detected by using the Coccinelle software. Signed-off-by: Markus Elfring <elfring@users.sourceforge.net> Acked-by: Casey Schaufler <casey@schaufler-ca.com>
Diffstat (limited to 'security/smack')
-rw-r--r--security/smack/smackfs.c11
1 files changed, 3 insertions, 8 deletions
diff --git a/security/smack/smackfs.c b/security/smack/smackfs.c
index e249a66db533..6492fe96cae4 100644
--- a/security/smack/smackfs.c
+++ b/security/smack/smackfs.c
@@ -2523,14 +2523,9 @@ static ssize_t smk_write_revoke_subj(struct file *file, const char __user *buf,
if (count == 0 || count > SMK_LONGLABEL)
return -EINVAL;
- data = kzalloc(count, GFP_KERNEL);
- if (data == NULL)
- return -ENOMEM;
-
- if (copy_from_user(data, buf, count) != 0) {
- rc = -EFAULT;
- goto out_data;
- }
+ data = memdup_user(buf, count);
+ if (IS_ERR(data))
+ return PTR_ERR(data);
cp = smk_parse_smack(data, count);
if (IS_ERR(cp)) {