summaryrefslogtreecommitdiffstats
path: root/net/tipc/socket.c
diff options
context:
space:
mode:
authorwangweidong <wangweidong1@huawei.com>2013-12-12 02:36:42 +0100
committerDavid S. Miller <davem@davemloft.net>2013-12-16 18:48:35 +0100
commitd3fbccf2b01f8262faa1479712be6a55c626bdef (patch)
tree4f46ab8e4e49db33fcb9a95a7381c2aa4f37a8f2 /net/tipc/socket.c
parenttipc: Use <linux/uaccess.h> instead of <asm/uaccess.h> (diff)
downloadlinux-d3fbccf2b01f8262faa1479712be6a55c626bdef.tar.xz
linux-d3fbccf2b01f8262faa1479712be6a55c626bdef.zip
tipc: change lock_sock order in connect()
Instead of reaquiring the socket lock and taking the normal exit path when a connection times out, we bail out early with a return -ETIMEDOUT. Reviewed-by: Jon Maloy <jon.maloy@ericsson.com> Reviewed-by: Erik Hugne <erik.hugne@ericsson.com> Signed-off-by: Wang Weidong <wangweidong1@huawei.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to '')
-rw-r--r--net/tipc/socket.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/net/tipc/socket.c b/net/tipc/socket.c
index 844bf349bb81..83f466e57fea 100644
--- a/net/tipc/socket.c
+++ b/net/tipc/socket.c
@@ -1507,14 +1507,12 @@ static int connect(struct socket *sock, struct sockaddr *dest, int destlen,
sock->state != SS_CONNECTING,
timeout ? (long)msecs_to_jiffies(timeout)
: MAX_SCHEDULE_TIMEOUT);
- lock_sock(sk);
if (res <= 0) {
if (res == 0)
res = -ETIMEDOUT;
- else
- ; /* leave "res" unchanged */
- goto exit;
+ return res;
}
+ lock_sock(sk);
}
if (unlikely(sock->state == SS_DISCONNECTING))