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

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
This commit is contained in:
Al Viro 2017-05-13 18:16:28 -04:00
parent 02412e9b4e
commit 7f2d17c67a
1 changed files with 3 additions and 8 deletions

View File

@ -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;
}