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.c134
1 files changed, 52 insertions, 82 deletions
diff --git a/net/sctp/socket.c b/net/sctp/socket.c
index 33354602ae86..772fbfb4bfda 100644
--- a/net/sctp/socket.c
+++ b/net/sctp/socket.c
@@ -367,14 +367,10 @@ SCTP_STATIC int sctp_do_bind(struct sock *sk, union sctp_addr *addr, int len)
367 if (!bp->port) 367 if (!bp->port)
368 bp->port = inet_sk(sk)->num; 368 bp->port = inet_sk(sk)->num;
369 369
370 /* Add the address to the bind address list. */ 370 /* Add the address to the bind address list.
371 sctp_local_bh_disable(); 371 * Use GFP_ATOMIC since BHs will be disabled.
372 sctp_write_lock(&ep->base.addr_lock); 372 */
373
374 /* Use GFP_ATOMIC since BHs are disabled. */
375 ret = sctp_add_bind_addr(bp, addr, 1, GFP_ATOMIC); 373 ret = sctp_add_bind_addr(bp, addr, 1, GFP_ATOMIC);
376 sctp_write_unlock(&ep->base.addr_lock);
377 sctp_local_bh_enable();
378 374
379 /* Copy back into socket for getsockname() use. */ 375 /* Copy back into socket for getsockname() use. */
380 if (!ret) { 376 if (!ret) {
@@ -544,15 +540,12 @@ static int sctp_send_asconf_add_ip(struct sock *sk,
544 if (i < addrcnt) 540 if (i < addrcnt)
545 continue; 541 continue;
546 542
547 /* Use the first address in bind addr list of association as 543 /* Use the first valid address in bind addr list of
548 * Address Parameter of ASCONF CHUNK. 544 * association as Address Parameter of ASCONF CHUNK.
549 */ 545 */
550 sctp_read_lock(&asoc->base.addr_lock);
551 bp = &asoc->base.bind_addr; 546 bp = &asoc->base.bind_addr;
552 p = bp->address_list.next; 547 p = bp->address_list.next;
553 laddr = list_entry(p, struct sctp_sockaddr_entry, list); 548 laddr = list_entry(p, struct sctp_sockaddr_entry, list);
554 sctp_read_unlock(&asoc->base.addr_lock);
555
556 chunk = sctp_make_asconf_update_ip(asoc, &laddr->a, addrs, 549 chunk = sctp_make_asconf_update_ip(asoc, &laddr->a, addrs,
557 addrcnt, SCTP_PARAM_ADD_IP); 550 addrcnt, SCTP_PARAM_ADD_IP);
558 if (!chunk) { 551 if (!chunk) {
@@ -567,8 +560,6 @@ static int sctp_send_asconf_add_ip(struct sock *sk,
567 /* Add the new addresses to the bind address list with 560 /* Add the new addresses to the bind address list with
568 * use_as_src set to 0. 561 * use_as_src set to 0.
569 */ 562 */
570 sctp_local_bh_disable();
571 sctp_write_lock(&asoc->base.addr_lock);
572 addr_buf = addrs; 563 addr_buf = addrs;
573 for (i = 0; i < addrcnt; i++) { 564 for (i = 0; i < addrcnt; i++) {
574 addr = (union sctp_addr *)addr_buf; 565 addr = (union sctp_addr *)addr_buf;
@@ -578,8 +569,6 @@ static int sctp_send_asconf_add_ip(struct sock *sk,
578 GFP_ATOMIC); 569 GFP_ATOMIC);
579 addr_buf += af->sockaddr_len; 570 addr_buf += af->sockaddr_len;
580 } 571 }
581 sctp_write_unlock(&asoc->base.addr_lock);
582 sctp_local_bh_enable();
583 } 572 }
584 573
585out: 574out:
@@ -651,13 +640,7 @@ static int sctp_bindx_rem(struct sock *sk, struct sockaddr *addrs, int addrcnt)
651 * socket routing and failover schemes. Refer to comments in 640 * socket routing and failover schemes. Refer to comments in
652 * sctp_do_bind(). -daisy 641 * sctp_do_bind(). -daisy
653 */ 642 */
654 sctp_local_bh_disable(); 643 retval = sctp_del_bind_addr(bp, sa_addr, call_rcu);
655 sctp_write_lock(&ep->base.addr_lock);
656
657 retval = sctp_del_bind_addr(bp, sa_addr);
658
659 sctp_write_unlock(&ep->base.addr_lock);
660 sctp_local_bh_enable();
661 644
662 addr_buf += af->sockaddr_len; 645 addr_buf += af->sockaddr_len;
663err_bindx_rem: 646err_bindx_rem:
@@ -748,14 +731,16 @@ static int sctp_send_asconf_del_ip(struct sock *sk,
748 * make sure that we do not delete all the addresses in the 731 * make sure that we do not delete all the addresses in the
749 * association. 732 * association.
750 */ 733 */
751 sctp_read_lock(&asoc->base.addr_lock);
752 bp = &asoc->base.bind_addr; 734 bp = &asoc->base.bind_addr;
753 laddr = sctp_find_unmatch_addr(bp, (union sctp_addr *)addrs, 735 laddr = sctp_find_unmatch_addr(bp, (union sctp_addr *)addrs,
754 addrcnt, sp); 736 addrcnt, sp);
755 sctp_read_unlock(&asoc->base.addr_lock);
756 if (!laddr) 737 if (!laddr)
757 continue; 738 continue;
758 739
740 /* We do not need RCU protection throughout this loop
741 * because this is done under a socket lock from the
742 * setsockopt call.
743 */
759 chunk = sctp_make_asconf_update_ip(asoc, laddr, addrs, addrcnt, 744 chunk = sctp_make_asconf_update_ip(asoc, laddr, addrs, addrcnt,
760 SCTP_PARAM_DEL_IP); 745 SCTP_PARAM_DEL_IP);
761 if (!chunk) { 746 if (!chunk) {
@@ -766,23 +751,16 @@ static int sctp_send_asconf_del_ip(struct sock *sk,
766 /* Reset use_as_src flag for the addresses in the bind address 751 /* Reset use_as_src flag for the addresses in the bind address
767 * list that are to be deleted. 752 * list that are to be deleted.
768 */ 753 */
769 sctp_local_bh_disable();
770 sctp_write_lock(&asoc->base.addr_lock);
771 addr_buf = addrs; 754 addr_buf = addrs;
772 for (i = 0; i < addrcnt; i++) { 755 for (i = 0; i < addrcnt; i++) {
773 laddr = (union sctp_addr *)addr_buf; 756 laddr = (union sctp_addr *)addr_buf;
774 af = sctp_get_af_specific(laddr->v4.sin_family); 757 af = sctp_get_af_specific(laddr->v4.sin_family);
775 list_for_each(pos1, &bp->address_list) { 758 list_for_each_entry(saddr, &bp->address_list, list) {
776 saddr = list_entry(pos1,
777 struct sctp_sockaddr_entry,
778 list);
779 if (sctp_cmp_addr_exact(&saddr->a, laddr)) 759 if (sctp_cmp_addr_exact(&saddr->a, laddr))
780 saddr->use_as_src = 0; 760 saddr->use_as_src = 0;
781 } 761 }
782 addr_buf += af->sockaddr_len; 762 addr_buf += af->sockaddr_len;
783 } 763 }
784 sctp_write_unlock(&asoc->base.addr_lock);
785 sctp_local_bh_enable();
786 764
787 /* Update the route and saddr entries for all the transports 765 /* Update the route and saddr entries for all the transports
788 * as some of the addresses in the bind address list are 766 * as some of the addresses in the bind address list are
@@ -4059,9 +4037,7 @@ static int sctp_getsockopt_local_addrs_num_old(struct sock *sk, int len,
4059 sctp_assoc_t id; 4037 sctp_assoc_t id;
4060 struct sctp_bind_addr *bp; 4038 struct sctp_bind_addr *bp;
4061 struct sctp_association *asoc; 4039 struct sctp_association *asoc;
4062 struct list_head *pos, *temp;
4063 struct sctp_sockaddr_entry *addr; 4040 struct sctp_sockaddr_entry *addr;
4064 rwlock_t *addr_lock;
4065 int cnt = 0; 4041 int cnt = 0;
4066 4042
4067 if (len < sizeof(sctp_assoc_t)) 4043 if (len < sizeof(sctp_assoc_t))
@@ -4078,17 +4054,13 @@ static int sctp_getsockopt_local_addrs_num_old(struct sock *sk, int len,
4078 */ 4054 */
4079 if (0 == id) { 4055 if (0 == id) {
4080 bp = &sctp_sk(sk)->ep->base.bind_addr; 4056 bp = &sctp_sk(sk)->ep->base.bind_addr;
4081 addr_lock = &sctp_sk(sk)->ep->base.addr_lock;
4082 } else { 4057 } else {
4083 asoc = sctp_id2assoc(sk, id); 4058 asoc = sctp_id2assoc(sk, id);
4084 if (!asoc) 4059 if (!asoc)
4085 return -EINVAL; 4060 return -EINVAL;
4086 bp = &asoc->base.bind_addr; 4061 bp = &asoc->base.bind_addr;
4087 addr_lock = &asoc->base.addr_lock;
4088 } 4062 }
4089 4063
4090 sctp_read_lock(addr_lock);
4091
4092 /* If the endpoint is bound to 0.0.0.0 or ::0, count the valid 4064 /* If the endpoint is bound to 0.0.0.0 or ::0, count the valid
4093 * addresses from the global local address list. 4065 * addresses from the global local address list.
4094 */ 4066 */
@@ -4096,27 +4068,33 @@ static int sctp_getsockopt_local_addrs_num_old(struct sock *sk, int len,
4096 addr = list_entry(bp->address_list.next, 4068 addr = list_entry(bp->address_list.next,
4097 struct sctp_sockaddr_entry, list); 4069 struct sctp_sockaddr_entry, list);
4098 if (sctp_is_any(&addr->a)) { 4070 if (sctp_is_any(&addr->a)) {
4099 list_for_each_safe(pos, temp, &sctp_local_addr_list) { 4071 rcu_read_lock();
4100 addr = list_entry(pos, 4072 list_for_each_entry_rcu(addr,
4101 struct sctp_sockaddr_entry, 4073 &sctp_local_addr_list, list) {
4102 list); 4074 if (!addr->valid)
4075 continue;
4076
4103 if ((PF_INET == sk->sk_family) && 4077 if ((PF_INET == sk->sk_family) &&
4104 (AF_INET6 == addr->a.sa.sa_family)) 4078 (AF_INET6 == addr->a.sa.sa_family))
4105 continue; 4079 continue;
4080
4106 cnt++; 4081 cnt++;
4107 } 4082 }
4083 rcu_read_unlock();
4108 } else { 4084 } else {
4109 cnt = 1; 4085 cnt = 1;
4110 } 4086 }
4111 goto done; 4087 goto done;
4112 } 4088 }
4113 4089
4114 list_for_each(pos, &bp->address_list) { 4090 /* Protection on the bound address list is not needed,
4091 * since in the socket option context we hold the socket lock,
4092 * so there is no way that the bound address list can change.
4093 */
4094 list_for_each_entry(addr, &bp->address_list, list) {
4115 cnt ++; 4095 cnt ++;
4116 } 4096 }
4117
4118done: 4097done:
4119 sctp_read_unlock(addr_lock);
4120 return cnt; 4098 return cnt;
4121} 4099}
4122 4100
@@ -4127,14 +4105,16 @@ static int sctp_copy_laddrs_old(struct sock *sk, __u16 port,
4127 int max_addrs, void *to, 4105 int max_addrs, void *to,
4128 int *bytes_copied) 4106 int *bytes_copied)
4129{ 4107{
4130 struct list_head *pos, *next;
4131 struct sctp_sockaddr_entry *addr; 4108 struct sctp_sockaddr_entry *addr;
4132 union sctp_addr temp; 4109 union sctp_addr temp;
4133 int cnt = 0; 4110 int cnt = 0;
4134 int addrlen; 4111 int addrlen;
4135 4112
4136 list_for_each_safe(pos, next, &sctp_local_addr_list) { 4113 rcu_read_lock();
4137 addr = list_entry(pos, struct sctp_sockaddr_entry, list); 4114 list_for_each_entry_rcu(addr, &sctp_local_addr_list, list) {
4115 if (!addr->valid)
4116 continue;
4117
4138 if ((PF_INET == sk->sk_family) && 4118 if ((PF_INET == sk->sk_family) &&
4139 (AF_INET6 == addr->a.sa.sa_family)) 4119 (AF_INET6 == addr->a.sa.sa_family))
4140 continue; 4120 continue;
@@ -4149,6 +4129,7 @@ static int sctp_copy_laddrs_old(struct sock *sk, __u16 port,
4149 cnt ++; 4129 cnt ++;
4150 if (cnt >= max_addrs) break; 4130 if (cnt >= max_addrs) break;
4151 } 4131 }
4132 rcu_read_unlock();
4152 4133
4153 return cnt; 4134 return cnt;
4154} 4135}
@@ -4156,14 +4137,16 @@ static int sctp_copy_laddrs_old(struct sock *sk, __u16 port,
4156static int sctp_copy_laddrs(struct sock *sk, __u16 port, void *to, 4137static int sctp_copy_laddrs(struct sock *sk, __u16 port, void *to,
4157 size_t space_left, int *bytes_copied) 4138 size_t space_left, int *bytes_copied)
4158{ 4139{
4159 struct list_head *pos, *next;
4160 struct sctp_sockaddr_entry *addr; 4140 struct sctp_sockaddr_entry *addr;
4161 union sctp_addr temp; 4141 union sctp_addr temp;
4162 int cnt = 0; 4142 int cnt = 0;
4163 int addrlen; 4143 int addrlen;
4164 4144
4165 list_for_each_safe(pos, next, &sctp_local_addr_list) { 4145 rcu_read_lock();
4166 addr = list_entry(pos, struct sctp_sockaddr_entry, list); 4146 list_for_each_entry_rcu(addr, &sctp_local_addr_list, list) {
4147 if (!addr->valid)
4148 continue;
4149
4167 if ((PF_INET == sk->sk_family) && 4150 if ((PF_INET == sk->sk_family) &&
4168 (AF_INET6 == addr->a.sa.sa_family)) 4151 (AF_INET6 == addr->a.sa.sa_family))
4169 continue; 4152 continue;
@@ -4171,8 +4154,10 @@ static int sctp_copy_laddrs(struct sock *sk, __u16 port, void *to,
4171 sctp_get_pf_specific(sk->sk_family)->addr_v4map(sctp_sk(sk), 4154 sctp_get_pf_specific(sk->sk_family)->addr_v4map(sctp_sk(sk),
4172 &temp); 4155 &temp);
4173 addrlen = sctp_get_af_specific(temp.sa.sa_family)->sockaddr_len; 4156 addrlen = sctp_get_af_specific(temp.sa.sa_family)->sockaddr_len;
4174 if (space_left < addrlen) 4157 if (space_left < addrlen) {
4175 return -ENOMEM; 4158 cnt = -ENOMEM;
4159 break;
4160 }
4176 memcpy(to, &temp, addrlen); 4161 memcpy(to, &temp, addrlen);
4177 4162
4178 to += addrlen; 4163 to += addrlen;
@@ -4180,6 +4165,7 @@ static int sctp_copy_laddrs(struct sock *sk, __u16 port, void *to,
4180 space_left -= addrlen; 4165 space_left -= addrlen;
4181 *bytes_copied += addrlen; 4166 *bytes_copied += addrlen;
4182 } 4167 }
4168 rcu_read_unlock();
4183 4169
4184 return cnt; 4170 return cnt;
4185} 4171}
@@ -4192,7 +4178,6 @@ static int sctp_getsockopt_local_addrs_old(struct sock *sk, int len,
4192{ 4178{
4193 struct sctp_bind_addr *bp; 4179 struct sctp_bind_addr *bp;
4194 struct sctp_association *asoc; 4180 struct sctp_association *asoc;
4195 struct list_head *pos;
4196 int cnt = 0; 4181 int cnt = 0;
4197 struct sctp_getaddrs_old getaddrs; 4182 struct sctp_getaddrs_old getaddrs;
4198 struct sctp_sockaddr_entry *addr; 4183 struct sctp_sockaddr_entry *addr;
@@ -4200,7 +4185,6 @@ static int sctp_getsockopt_local_addrs_old(struct sock *sk, int len,
4200 union sctp_addr temp; 4185 union sctp_addr temp;
4201 struct sctp_sock *sp = sctp_sk(sk); 4186 struct sctp_sock *sp = sctp_sk(sk);
4202 int addrlen; 4187 int addrlen;
4203 rwlock_t *addr_lock;
4204 int err = 0; 4188 int err = 0;
4205 void *addrs; 4189 void *addrs;
4206 void *buf; 4190 void *buf;
@@ -4222,13 +4206,11 @@ static int sctp_getsockopt_local_addrs_old(struct sock *sk, int len,
4222 */ 4206 */
4223 if (0 == getaddrs.assoc_id) { 4207 if (0 == getaddrs.assoc_id) {
4224 bp = &sctp_sk(sk)->ep->base.bind_addr; 4208 bp = &sctp_sk(sk)->ep->base.bind_addr;
4225 addr_lock = &sctp_sk(sk)->ep->base.addr_lock;
4226 } else { 4209 } else {
4227 asoc = sctp_id2assoc(sk, getaddrs.assoc_id); 4210 asoc = sctp_id2assoc(sk, getaddrs.assoc_id);
4228 if (!asoc) 4211 if (!asoc)
4229 return -EINVAL; 4212 return -EINVAL;
4230 bp = &asoc->base.bind_addr; 4213 bp = &asoc->base.bind_addr;
4231 addr_lock = &asoc->base.addr_lock;
4232 } 4214 }
4233 4215
4234 to = getaddrs.addrs; 4216 to = getaddrs.addrs;
@@ -4242,8 +4224,6 @@ static int sctp_getsockopt_local_addrs_old(struct sock *sk, int len,
4242 if (!addrs) 4224 if (!addrs)
4243 return -ENOMEM; 4225 return -ENOMEM;
4244 4226
4245 sctp_read_lock(addr_lock);
4246
4247 /* If the endpoint is bound to 0.0.0.0 or ::0, get the valid 4227 /* If the endpoint is bound to 0.0.0.0 or ::0, get the valid
4248 * addresses from the global local address list. 4228 * addresses from the global local address list.
4249 */ 4229 */
@@ -4259,8 +4239,11 @@ static int sctp_getsockopt_local_addrs_old(struct sock *sk, int len,
4259 } 4239 }
4260 4240
4261 buf = addrs; 4241 buf = addrs;
4262 list_for_each(pos, &bp->address_list) { 4242 /* Protection on the bound address list is not needed since
4263 addr = list_entry(pos, struct sctp_sockaddr_entry, list); 4243 * in the socket option context we hold a socket lock and
4244 * thus the bound address list can't change.
4245 */
4246 list_for_each_entry(addr, &bp->address_list, list) {
4264 memcpy(&temp, &addr->a, sizeof(temp)); 4247 memcpy(&temp, &addr->a, sizeof(temp));
4265 sctp_get_pf_specific(sk->sk_family)->addr_v4map(sp, &temp); 4248 sctp_get_pf_specific(sk->sk_family)->addr_v4map(sp, &temp);
4266 addrlen = sctp_get_af_specific(temp.sa.sa_family)->sockaddr_len; 4249 addrlen = sctp_get_af_specific(temp.sa.sa_family)->sockaddr_len;
@@ -4272,8 +4255,6 @@ static int sctp_getsockopt_local_addrs_old(struct sock *sk, int len,
4272 } 4255 }
4273 4256
4274copy_getaddrs: 4257copy_getaddrs:
4275 sctp_read_unlock(addr_lock);
4276
4277 /* copy the entire address list into the user provided space */ 4258 /* copy the entire address list into the user provided space */
4278 if (copy_to_user(to, addrs, bytes_copied)) { 4259 if (copy_to_user(to, addrs, bytes_copied)) {
4279 err = -EFAULT; 4260 err = -EFAULT;
@@ -4295,7 +4276,6 @@ static int sctp_getsockopt_local_addrs(struct sock *sk, int len,
4295{ 4276{
4296 struct sctp_bind_addr *bp; 4277 struct sctp_bind_addr *bp;
4297 struct sctp_association *asoc; 4278 struct sctp_association *asoc;
4298 struct list_head *pos;
4299 int cnt = 0; 4279 int cnt = 0;
4300 struct sctp_getaddrs getaddrs; 4280 struct sctp_getaddrs getaddrs;
4301 struct sctp_sockaddr_entry *addr; 4281 struct sctp_sockaddr_entry *addr;
@@ -4303,7 +4283,6 @@ static int sctp_getsockopt_local_addrs(struct sock *sk, int len,
4303 union sctp_addr temp; 4283 union sctp_addr temp;
4304 struct sctp_sock *sp = sctp_sk(sk); 4284 struct sctp_sock *sp = sctp_sk(sk);
4305 int addrlen; 4285 int addrlen;
4306 rwlock_t *addr_lock;
4307 int err = 0; 4286 int err = 0;
4308 size_t space_left; 4287 size_t space_left;
4309 int bytes_copied = 0; 4288 int bytes_copied = 0;
@@ -4324,13 +4303,11 @@ static int sctp_getsockopt_local_addrs(struct sock *sk, int len,
4324 */ 4303 */
4325 if (0 == getaddrs.assoc_id) { 4304 if (0 == getaddrs.assoc_id) {
4326 bp = &sctp_sk(sk)->ep->base.bind_addr; 4305 bp = &sctp_sk(sk)->ep->base.bind_addr;
4327 addr_lock = &sctp_sk(sk)->ep->base.addr_lock;
4328 } else { 4306 } else {
4329 asoc = sctp_id2assoc(sk, getaddrs.assoc_id); 4307 asoc = sctp_id2assoc(sk, getaddrs.assoc_id);
4330 if (!asoc) 4308 if (!asoc)
4331 return -EINVAL; 4309 return -EINVAL;
4332 bp = &asoc->base.bind_addr; 4310 bp = &asoc->base.bind_addr;
4333 addr_lock = &asoc->base.addr_lock;
4334 } 4311 }
4335 4312
4336 to = optval + offsetof(struct sctp_getaddrs,addrs); 4313 to = optval + offsetof(struct sctp_getaddrs,addrs);
@@ -4340,8 +4317,6 @@ static int sctp_getsockopt_local_addrs(struct sock *sk, int len,
4340 if (!addrs) 4317 if (!addrs)
4341 return -ENOMEM; 4318 return -ENOMEM;
4342 4319
4343 sctp_read_lock(addr_lock);
4344
4345 /* If the endpoint is bound to 0.0.0.0 or ::0, get the valid 4320 /* If the endpoint is bound to 0.0.0.0 or ::0, get the valid
4346 * addresses from the global local address list. 4321 * addresses from the global local address list.
4347 */ 4322 */
@@ -4353,21 +4328,24 @@ static int sctp_getsockopt_local_addrs(struct sock *sk, int len,
4353 space_left, &bytes_copied); 4328 space_left, &bytes_copied);
4354 if (cnt < 0) { 4329 if (cnt < 0) {
4355 err = cnt; 4330 err = cnt;
4356 goto error_lock; 4331 goto out;
4357 } 4332 }
4358 goto copy_getaddrs; 4333 goto copy_getaddrs;
4359 } 4334 }
4360 } 4335 }
4361 4336
4362 buf = addrs; 4337 buf = addrs;
4363 list_for_each(pos, &bp->address_list) { 4338 /* Protection on the bound address list is not needed since
4364 addr = list_entry(pos, struct sctp_sockaddr_entry, list); 4339 * in the socket option context we hold a socket lock and
4340 * thus the bound address list can't change.
4341 */
4342 list_for_each_entry(addr, &bp->address_list, list) {
4365 memcpy(&temp, &addr->a, sizeof(temp)); 4343 memcpy(&temp, &addr->a, sizeof(temp));
4366 sctp_get_pf_specific(sk->sk_family)->addr_v4map(sp, &temp); 4344 sctp_get_pf_specific(sk->sk_family)->addr_v4map(sp, &temp);
4367 addrlen = sctp_get_af_specific(temp.sa.sa_family)->sockaddr_len; 4345 addrlen = sctp_get_af_specific(temp.sa.sa_family)->sockaddr_len;
4368 if (space_left < addrlen) { 4346 if (space_left < addrlen) {
4369 err = -ENOMEM; /*fixme: right error?*/ 4347 err = -ENOMEM; /*fixme: right error?*/
4370 goto error_lock; 4348 goto out;
4371 } 4349 }
4372 memcpy(buf, &temp, addrlen); 4350 memcpy(buf, &temp, addrlen);
4373 buf += addrlen; 4351 buf += addrlen;
@@ -4377,8 +4355,6 @@ static int sctp_getsockopt_local_addrs(struct sock *sk, int len,
4377 } 4355 }
4378 4356
4379copy_getaddrs: 4357copy_getaddrs:
4380 sctp_read_unlock(addr_lock);
4381
4382 if (copy_to_user(to, addrs, bytes_copied)) { 4358 if (copy_to_user(to, addrs, bytes_copied)) {
4383 err = -EFAULT; 4359 err = -EFAULT;
4384 goto out; 4360 goto out;
@@ -4389,12 +4365,6 @@ copy_getaddrs:
4389 } 4365 }
4390 if (put_user(bytes_copied, optlen)) 4366 if (put_user(bytes_copied, optlen))
4391 err = -EFAULT; 4367 err = -EFAULT;
4392
4393 goto out;
4394
4395error_lock:
4396 sctp_read_unlock(addr_lock);
4397
4398out: 4368out:
4399 kfree(addrs); 4369 kfree(addrs);
4400 return err; 4370 return err;