Skip to content

Commit d3fbccf

Browse files
wangweidongdavem330
authored andcommitted
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>
1 parent 776a74c commit d3fbccf

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

net/tipc/socket.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1507,14 +1507,12 @@ static int connect(struct socket *sock, struct sockaddr *dest, int destlen,
15071507
sock->state != SS_CONNECTING,
15081508
timeout ? (long)msecs_to_jiffies(timeout)
15091509
: MAX_SCHEDULE_TIMEOUT);
1510-
lock_sock(sk);
15111510
if (res <= 0) {
15121511
if (res == 0)
15131512
res = -ETIMEDOUT;
1514-
else
1515-
; /* leave "res" unchanged */
1516-
goto exit;
1513+
return res;
15171514
}
1515+
lock_sock(sk);
15181516
}
15191517

15201518
if (unlikely(sock->state == SS_DISCONNECTING))

0 commit comments

Comments
 (0)