Commit 7f2d17c6 authored by Al Viro's avatar Al Viro

xfrm_user_policy(): don't open-code memdup_user()

Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
parent 02412e9b
...@@ -2023,13 +2023,9 @@ int xfrm_user_policy(struct sock *sk, int optname, u8 __user *optval, int optlen ...@@ -2023,13 +2023,9 @@ int xfrm_user_policy(struct sock *sk, int optname, u8 __user *optval, int optlen
if (optlen <= 0 || optlen > PAGE_SIZE) if (optlen <= 0 || optlen > PAGE_SIZE)
return -EMSGSIZE; return -EMSGSIZE;
data = kmalloc(optlen, GFP_KERNEL); data = memdup_user(optval, optlen);
if (!data) if (IS_ERR(data))
return -ENOMEM; return PTR_ERR(data);
err = -EFAULT;
if (copy_from_user(data, optval, optlen))
goto out;
err = -EINVAL; err = -EINVAL;
rcu_read_lock(); rcu_read_lock();
...@@ -2047,7 +2043,6 @@ int xfrm_user_policy(struct sock *sk, int optname, u8 __user *optval, int optlen ...@@ -2047,7 +2043,6 @@ int xfrm_user_policy(struct sock *sk, int optname, u8 __user *optval, int optlen
err = 0; err = 0;
} }
out:
kfree(data); kfree(data);
return err; return err;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment