Skip to contentSkip to conversation

net: Fix the condition passed to sk_wait_event()

PATCH New Nagendra Tomar 1 participant 1 message Oct 2, 2010

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 net: Fix the condition passed to sk_wait_event()

This patch fixes the sk_wait_event() condition in the sk_stream_wait_connect() function. With this change, we correctly check for the TCPF_ESTABLISHED and TCPF_CLOSE_WAIT states and avoid potentially returning success when there might be an error on the socket.

---

net/core/stream.c renamed from net/core/stream.c.orig +2 -3
@@ -73,9 +73,8 @@ int sk_stream_wait_connect(struct sock *
 		prepare_to_wait(sk_sleep(sk), &wait, TASK_INTERRUPTIBLE);
 		sk->sk_write_pending++;
 		done = sk_wait_event(sk, timeo_p,
-				     !sk->sk_err &&
-				     !((1 << sk->sk_state) &
-				       ~(TCPF_ESTABLISHED | TCPF_CLOSE_WAIT)));
+				     ((1 << sk->sk_state) &
+				       (TCPF_ESTABLISHED | TCPF_CLOSE_WAIT)));
 		finish_wait(sk_sleep(sk), &wait);
 		sk->sk_write_pending--;
 	} while (!done);

---