sctp: try to fix readlock
authorSebastian Siewior <sebastian@breakpoint.cc>
Fri, 27 Jul 2007 20:55:59 +0000 (22:55 +0200)
committerVlad Yasevich <vladislav.yasevich@hp.com>
Wed, 1 Aug 2007 15:19:06 +0000 (11:19 -0400)
unlock the reader lock in error case.

Signed-off-by: Sebastian Siewior <sebastian@breakpoint.cc>
Signed-off-by: Vlad Yasevich <vladislav.yasevich@hp.com>
net/sctp/socket.c

index b31be0994572828a094b416b05d4e0792b252d9c..be743d4a7c096f68f56580c975efd35024cd3a54 100644 (file)
@@ -4350,7 +4350,7 @@ static int sctp_getsockopt_local_addrs(struct sock *sk, int len,
                                                space_left, &bytes_copied);
                        if (cnt < 0) {
                                err = cnt;
-                               goto error;
+                               goto error_lock;
                        }
                        goto copy_getaddrs;
                }
@@ -4364,7 +4364,7 @@ static int sctp_getsockopt_local_addrs(struct sock *sk, int len,
                addrlen = sctp_get_af_specific(temp.sa.sa_family)->sockaddr_len;
                if (space_left < addrlen) {
                        err =  -ENOMEM; /*fixme: right error?*/
-                       goto error;
+                       goto error_lock;
                }
                memcpy(buf, &temp, addrlen);
                buf += addrlen;
@@ -4378,15 +4378,21 @@ copy_getaddrs:
 
        if (copy_to_user(to, addrs, bytes_copied)) {
                err = -EFAULT;
-               goto error;
+               goto out;
        }
        if (put_user(cnt, &((struct sctp_getaddrs __user *)optval)->addr_num)) {
                err = -EFAULT;
-               goto error;
+               goto out;
        }
        if (put_user(bytes_copied, optlen))
                err = -EFAULT;
-error:
+
+       goto out;
+
+error_lock:
+       sctp_read_unlock(addr_lock);
+
+out:
        kfree(addrs);
        return err;
 }