X-Git-Url: https://git.saurik.com/apple/xnu.git/blobdiff_plain/91447636331957f3d9b5ca5b508f07c526b0074d..13fec9890cf095cc781fdf7b8917cb03bf32dd4c:/bsd/netinet/tcp_usrreq.c diff --git a/bsd/netinet/tcp_usrreq.c b/bsd/netinet/tcp_usrreq.c index d29331e28..2a5ab6988 100644 --- a/bsd/netinet/tcp_usrreq.c +++ b/bsd/netinet/tcp_usrreq.c @@ -754,9 +754,11 @@ tcp_connect(tp, nam, p) tcp_lock(inp->inp_socket, 0, 0); if (oinp) { - tcp_lock(oinp->inp_socket, 1, 0); + if (oinp != inp) /* 4143933: avoid deadlock if inp == oinp */ + tcp_lock(oinp->inp_socket, 1, 0); if (in_pcb_checkstate(oinp, WNT_RELEASE, 1) == WNT_STOPUSING) { - tcp_unlock(oinp->inp_socket, 1, 0); + if (oinp != inp) + tcp_unlock(oinp->inp_socket, 1, 0); goto skip_oinp; } @@ -767,10 +769,12 @@ tcp_connect(tp, nam, p) otp = tcp_close(otp); else { printf("tcp_connect: inp=%x err=EADDRINUSE\n", inp); - tcp_unlock(oinp->inp_socket, 1, 0); + if (oinp != inp) + tcp_unlock(oinp->inp_socket, 1, 0); return EADDRINUSE; } - tcp_unlock(oinp->inp_socket, 1, 0); + if (oinp != inp) + tcp_unlock(oinp->inp_socket, 1, 0); } skip_oinp: if ((inp->inp_laddr.s_addr == INADDR_ANY ? ifaddr->sin_addr.s_addr :