aboutsummaryrefslogtreecommitdiffstats
path: root/net/sctp/socket.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/sctp/socket.c')
-rw-r--r--net/sctp/socket.c24
1 files changed, 13 insertions, 11 deletions
diff --git a/net/sctp/socket.c b/net/sctp/socket.c
index 3e50a9712fb1..939b8d2595bc 100644
--- a/net/sctp/socket.c
+++ b/net/sctp/socket.c
@@ -309,7 +309,7 @@ static int sctp_bind(struct sock *sk, struct sockaddr *addr, int addr_len)
309 return retval; 309 return retval;
310} 310}
311 311
312static long sctp_get_port_local(struct sock *, union sctp_addr *); 312static int sctp_get_port_local(struct sock *, union sctp_addr *);
313 313
314/* Verify this is a valid sockaddr. */ 314/* Verify this is a valid sockaddr. */
315static struct sctp_af *sctp_sockaddr_af(struct sctp_sock *opt, 315static struct sctp_af *sctp_sockaddr_af(struct sctp_sock *opt,
@@ -399,9 +399,8 @@ static int sctp_do_bind(struct sock *sk, union sctp_addr *addr, int len)
399 * detection. 399 * detection.
400 */ 400 */
401 addr->v4.sin_port = htons(snum); 401 addr->v4.sin_port = htons(snum);
402 if ((ret = sctp_get_port_local(sk, addr))) { 402 if (sctp_get_port_local(sk, addr))
403 return -EADDRINUSE; 403 return -EADDRINUSE;
404 }
405 404
406 /* Refresh ephemeral port. */ 405 /* Refresh ephemeral port. */
407 if (!bp->port) 406 if (!bp->port)
@@ -413,11 +412,13 @@ static int sctp_do_bind(struct sock *sk, union sctp_addr *addr, int len)
413 ret = sctp_add_bind_addr(bp, addr, af->sockaddr_len, 412 ret = sctp_add_bind_addr(bp, addr, af->sockaddr_len,
414 SCTP_ADDR_SRC, GFP_ATOMIC); 413 SCTP_ADDR_SRC, GFP_ATOMIC);
415 414
416 /* Copy back into socket for getsockname() use. */ 415 if (ret) {
417 if (!ret) { 416 sctp_put_port(sk);
418 inet_sk(sk)->inet_sport = htons(inet_sk(sk)->inet_num); 417 return ret;
419 sp->pf->to_sk_saddr(addr, sk);
420 } 418 }
419 /* Copy back into socket for getsockname() use. */
420 inet_sk(sk)->inet_sport = htons(inet_sk(sk)->inet_num);
421 sp->pf->to_sk_saddr(addr, sk);
421 422
422 return ret; 423 return ret;
423} 424}
@@ -7192,7 +7193,7 @@ static int sctp_getsockopt_paddr_thresholds(struct sock *sk,
7192 val.spt_pathmaxrxt = trans->pathmaxrxt; 7193 val.spt_pathmaxrxt = trans->pathmaxrxt;
7193 val.spt_pathpfthld = trans->pf_retrans; 7194 val.spt_pathpfthld = trans->pf_retrans;
7194 7195
7195 return 0; 7196 goto out;
7196 } 7197 }
7197 7198
7198 asoc = sctp_id2assoc(sk, val.spt_assoc_id); 7199 asoc = sctp_id2assoc(sk, val.spt_assoc_id);
@@ -7210,6 +7211,7 @@ static int sctp_getsockopt_paddr_thresholds(struct sock *sk,
7210 val.spt_pathmaxrxt = sp->pathmaxrxt; 7211 val.spt_pathmaxrxt = sp->pathmaxrxt;
7211 } 7212 }
7212 7213
7214out:
7213 if (put_user(len, optlen) || copy_to_user(optval, &val, len)) 7215 if (put_user(len, optlen) || copy_to_user(optval, &val, len))
7214 return -EFAULT; 7216 return -EFAULT;
7215 7217
@@ -8145,7 +8147,7 @@ static void sctp_unhash(struct sock *sk)
8145static struct sctp_bind_bucket *sctp_bucket_create( 8147static struct sctp_bind_bucket *sctp_bucket_create(
8146 struct sctp_bind_hashbucket *head, struct net *, unsigned short snum); 8148 struct sctp_bind_hashbucket *head, struct net *, unsigned short snum);
8147 8149
8148static long sctp_get_port_local(struct sock *sk, union sctp_addr *addr) 8150static int sctp_get_port_local(struct sock *sk, union sctp_addr *addr)
8149{ 8151{
8150 struct sctp_sock *sp = sctp_sk(sk); 8152 struct sctp_sock *sp = sctp_sk(sk);
8151 bool reuse = (sk->sk_reuse || sp->reuse); 8153 bool reuse = (sk->sk_reuse || sp->reuse);
@@ -8255,7 +8257,7 @@ pp_found:
8255 8257
8256 if (sctp_bind_addr_conflict(&ep2->base.bind_addr, 8258 if (sctp_bind_addr_conflict(&ep2->base.bind_addr,
8257 addr, sp2, sp)) { 8259 addr, sp2, sp)) {
8258 ret = (long)sk2; 8260 ret = 1;
8259 goto fail_unlock; 8261 goto fail_unlock;
8260 } 8262 }
8261 } 8263 }
@@ -8327,7 +8329,7 @@ static int sctp_get_port(struct sock *sk, unsigned short snum)
8327 addr.v4.sin_port = htons(snum); 8329 addr.v4.sin_port = htons(snum);
8328 8330
8329 /* Note: sk->sk_num gets filled in if ephemeral port request. */ 8331 /* Note: sk->sk_num gets filled in if ephemeral port request. */
8330 return !!sctp_get_port_local(sk, &addr); 8332 return sctp_get_port_local(sk, &addr);
8331} 8333}
8332 8334
8333/* 8335/*