Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

wangweidong and committed by
David S. Miller
d3fbccf2 776a74ce

+2 -4
+2 -4
net/tipc/socket.c
··· 1507 1507 sock->state != SS_CONNECTING, 1508 1508 timeout ? (long)msecs_to_jiffies(timeout) 1509 1509 : MAX_SCHEDULE_TIMEOUT); 1510 - lock_sock(sk); 1511 1510 if (res <= 0) { 1512 1511 if (res == 0) 1513 1512 res = -ETIMEDOUT; 1514 - else 1515 - ; /* leave "res" unchanged */ 1516 - goto exit; 1513 + return res; 1517 1514 } 1515 + lock_sock(sk); 1518 1516 } 1519 1517 1520 1518 if (unlikely(sock->state == SS_DISCONNECTING))