diff options
author | Shan Wei <shanwei@cn.fujitsu.com> | 2011-04-18 19:13:18 +0000 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2011-04-19 21:45:20 -0700 |
commit | 934253a7b4ab4151037ea9532552628723a14442 (patch) | |
tree | 34958bbe96f709ff06c7e9ea77d44b96da3986d7 /net/sctp/socket.c | |
parent | 66009927f1e7374afdc6f9fdd25c493ee4eadf7c (diff) | |
download | blackbird-op-linux-934253a7b4ab4151037ea9532552628723a14442.tar.gz blackbird-op-linux-934253a7b4ab4151037ea9532552628723a14442.zip |
sctp: use memdup_user to copy data from userspace
Use common function to simply code.
Signed-off-by: Shan Wei <shanwei@cn.fujitsu.com>
Signed-off-by: Vlad Yasevich <vladislav.yasevich@hp.com>
Signed-off-by: Wei Yongjun <yjwei@cn.fujitsu.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/sctp/socket.c')
-rw-r--r-- | net/sctp/socket.c | 22 |
1 files changed, 6 insertions, 16 deletions
diff --git a/net/sctp/socket.c b/net/sctp/socket.c index deb82e35a107..5c9980ae36bb 100644 --- a/net/sctp/socket.c +++ b/net/sctp/socket.c @@ -3215,14 +3215,9 @@ static int sctp_setsockopt_hmac_ident(struct sock *sk, if (optlen < sizeof(struct sctp_hmacalgo)) return -EINVAL; - hmacs = kmalloc(optlen, GFP_KERNEL); - if (!hmacs) - return -ENOMEM; - - if (copy_from_user(hmacs, optval, optlen)) { - err = -EFAULT; - goto out; - } + hmacs= memdup_user(optval, optlen); + if (IS_ERR(hmacs)) + return PTR_ERR(hmacs); idents = hmacs->shmac_num_idents; if (idents == 0 || idents > SCTP_AUTH_NUM_HMACS || @@ -3257,14 +3252,9 @@ static int sctp_setsockopt_auth_key(struct sock *sk, if (optlen <= sizeof(struct sctp_authkey)) return -EINVAL; - authkey = kmalloc(optlen, GFP_KERNEL); - if (!authkey) - return -ENOMEM; - - if (copy_from_user(authkey, optval, optlen)) { - ret = -EFAULT; - goto out; - } + authkey= memdup_user(optval, optlen); + if (IS_ERR(authkey)) + return PTR_ERR(authkey); if (authkey->sca_keylength > optlen - sizeof(struct sctp_authkey)) { ret = -EINVAL; |