summaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2017-05-13 18:16:28 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2017-06-30 02:04:07 -0400
commit7f2d17c67ae3a0954e35092564f1cf58726b2c44 (patch)
treea994866af9e81e5199a273c4f3741abceecd0476 /net
parent02412e9b4e54e124fe0890b30b891d3e6f3adf38 (diff)
downloadop-kernel-dev-7f2d17c67ae3a0954e35092564f1cf58726b2c44.zip
op-kernel-dev-7f2d17c67ae3a0954e35092564f1cf58726b2c44.tar.gz
xfrm_user_policy(): don't open-code memdup_user()
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'net')
-rw-r--r--net/xfrm/xfrm_state.c11
1 files changed, 3 insertions, 8 deletions
diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c
index fc3c5aa..5780cda 100644
--- a/net/xfrm/xfrm_state.c
+++ b/net/xfrm/xfrm_state.c
@@ -2023,13 +2023,9 @@ int xfrm_user_policy(struct sock *sk, int optname, u8 __user *optval, int optlen
if (optlen <= 0 || optlen > PAGE_SIZE)
return -EMSGSIZE;
- data = kmalloc(optlen, GFP_KERNEL);
- if (!data)
- return -ENOMEM;
-
- err = -EFAULT;
- if (copy_from_user(data, optval, optlen))
- goto out;
+ data = memdup_user(optval, optlen);
+ if (IS_ERR(data))
+ return PTR_ERR(data);
err = -EINVAL;
rcu_read_lock();
@@ -2047,7 +2043,6 @@ int xfrm_user_policy(struct sock *sk, int optname, u8 __user *optval, int optlen
err = 0;
}
-out:
kfree(data);
return err;
}
OpenPOWER on IntegriCloud