From: Li Zefan Date: Wed, 8 Apr 2009 07:06:12 +0000 (+0800) Subject: xattr: use memdup_user() X-Git-Tag: firefly_0821_release~14399^2~9 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=3939fcde24473dc09ce16e922c88df9b3bee45d9;p=firefly-linux-kernel-4.4.55.git xattr: use memdup_user() Remove open-coded memdup_user() Signed-off-by: Li Zefan Signed-off-by: Al Viro --- diff --git a/fs/xattr.c b/fs/xattr.c index 197c4fcac032..d51b8f9db921 100644 --- a/fs/xattr.c +++ b/fs/xattr.c @@ -237,13 +237,9 @@ setxattr(struct dentry *d, const char __user *name, const void __user *value, if (size) { if (size > XATTR_SIZE_MAX) return -E2BIG; - kvalue = kmalloc(size, GFP_KERNEL); - if (!kvalue) - return -ENOMEM; - if (copy_from_user(kvalue, value, size)) { - kfree(kvalue); - return -EFAULT; - } + kvalue = memdup_user(value, size); + if (IS_ERR(kvalue)) + return PTR_ERR(kvalue); } error = vfs_setxattr(d, kname, kvalue, size, flags);