git: 37a7f5573716 - main - tcp_usr_rcvd: don't cast inp_ppcb to tcpcb before checking inp_flags

From: Gleb Smirnoff <glebius_at_FreeBSD.org>
Date: Mon, 27 Dec 2021 18:43:09 UTC
The branch main has been updated by glebius:

URL: https://cgit.FreeBSD.org/src/commit/?id=37a7f55737164e05d4bc4fa1f6510b4e624b6c45

commit 37a7f55737164e05d4bc4fa1f6510b4e624b6c45
Author:     Gleb Smirnoff <glebius@FreeBSD.org>
AuthorDate: 2021-12-27 18:41:51 +0000
Commit:     Gleb Smirnoff <glebius@FreeBSD.org>
CommitDate: 2021-12-27 18:41:51 +0000

    tcp_usr_rcvd: don't cast inp_ppcb to tcpcb before checking inp_flags
    
    Fixes:  f64dc2ab5be38e5366271ef85ea90d8cb1c7841a
---
 sys/netinet/tcp_usrreq.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/sys/netinet/tcp_usrreq.c b/sys/netinet/tcp_usrreq.c
index 06dee4c90ed6..7c791e0c4871 100644
--- a/sys/netinet/tcp_usrreq.c
+++ b/sys/netinet/tcp_usrreq.c
@@ -934,12 +934,12 @@ tcp_usr_rcvd(struct socket *so, int flags)
 	inp = sotoinpcb(so);
 	KASSERT(inp != NULL, ("tcp_usr_rcvd: inp == NULL"));
 	INP_WLOCK(inp);
-	NET_EPOCH_ENTER(et);
-	tp = intotcpcb(inp);
 	if (inp->inp_flags & (INP_TIMEWAIT | INP_DROPPED)) {
-		error = ECONNRESET;
-		goto out;
+		INP_WUNLOCK(inp);
+		return (ECONNRESET);
 	}
+	tp = intotcpcb(inp);
+	NET_EPOCH_ENTER(et);
 	TCPDEBUG1();
 	/*
 	 * For passively-created TFO connections, don't attempt a window