]> git.baikalelectronics.ru Git - kernel.git/commit
tipc: fix wrong connect() return code
authorTuong Lien <tuong.t.lien@dektech.com.au>
Wed, 8 Jan 2020 02:19:00 +0000 (09:19 +0700)
committerDavid S. Miller <davem@davemloft.net>
Wed, 8 Jan 2020 23:57:35 +0000 (15:57 -0800)
commit6a6522ed89054e98a45f0616cdaa28835b7e710a
tree277a8358430544f42aa02353b847932dec7d83e5
parentafd978300ee753977f31c89bd17ba9d76871d5f0
tipc: fix wrong connect() return code

The current 'tipc_wait_for_connect()' function does a wait-loop for the
condition 'sk->sk_state != TIPC_CONNECTING' to conclude if the socket
connecting has done. However, when the condition is met, it returns '0'
even in the case the connecting is actually failed, the socket state is
set to 'TIPC_DISCONNECTING' (e.g. when the server socket has closed..).
This results in a wrong return code for the 'connect()' call from user,
making it believe that the connection is established and go ahead with
building, sending a message, etc. but finally failed e.g. '-EPIPE'.

This commit fixes the issue by changing the wait condition to the
'tipc_sk_connected(sk)', so the function will return '0' only when the
connection is really established. Otherwise, either the socket 'sk_err'
if any or '-ETIMEDOUT'/'-EINTR' will be returned correspondingly.

Acked-by: Ying Xue <ying.xue@windriver.com>
Acked-by: Jon Maloy <jon.maloy@ericsson.com>
Signed-off-by: Tuong Lien <tuong.t.lien@dektech.com.au>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/tipc/socket.c