VSOCK: Don't set sk_state to TCP_CLOSE before testing it
authorJorgen Hansen <jhansen@vmware.com>
Mon, 27 Nov 2017 13:29:32 +0000 (05:29 -0800)
committerDavid S. Miller <davem@davemloft.net>
Tue, 28 Nov 2017 21:01:50 +0000 (16:01 -0500)
A recent commit (3b4477d2dcf2) converted the sk_state to use
TCP constants. In that change, vmci_transport_handle_detach
was changed such that sk->sk_state was set to TCP_CLOSE before
we test whether it is TCP_SYN_SENT. This change moves the
sk_state change back to the original locations in that function.

Signed-off-by: Jorgen Hansen <jhansen@vmware.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/vmw_vsock/vmci_transport.c

index 56573dc85709f995c9236b06ad9e72f7c1302957..a7a73ffe675b2a9e829a375e90fc3d055386dcf8 100644 (file)
@@ -804,8 +804,6 @@ static void vmci_transport_handle_detach(struct sock *sk)
                 */
                if (vsk->local_addr.svm_cid == VMADDR_CID_HOST ||
                    vsock_stream_has_data(vsk) <= 0) {
-                       sk->sk_state = TCP_CLOSE;
-
                        if (sk->sk_state == TCP_SYN_SENT) {
                                /* The peer may detach from a queue pair while
                                 * we are still in the connecting state, i.e.,
@@ -815,10 +813,12 @@ static void vmci_transport_handle_detach(struct sock *sk)
                                 * event like a reset.
                                 */
 
+                               sk->sk_state = TCP_CLOSE;
                                sk->sk_err = ECONNRESET;
                                sk->sk_error_report(sk);
                                return;
                        }
+                       sk->sk_state = TCP_CLOSE;
                }
                sk->sk_state_change(sk);
        }