diff options
author | Gleb Smirnoff <glebius@FreeBSD.org> | 2021-12-28 00:58:09 +0000 |
---|---|---|
committer | Gleb Smirnoff <glebius@FreeBSD.org> | 2021-12-28 00:58:09 +0000 |
commit | 0af4ce45472c3ddad8d1835815f5d09943fc7274 (patch) | |
tree | 67b2c812f3fbb5eaad9647a1b908d261ab6a2e48 | |
parent | d11f81afd5a4a71d5f725950b0592ca212084780 (diff) | |
download | src-0af4ce45472c3ddad8d1835815f5d09943fc7274.tar.gz src-0af4ce45472c3ddad8d1835815f5d09943fc7274.zip |
tcp_usr_shutdown: don't cast inp_ppcb to tcpcb before checking inp_flags
Fixes: f64dc2ab5be38e5366271ef85ea90d8cb1c7841a
-rw-r--r-- | sys/netinet/tcp_usrreq.c | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/sys/netinet/tcp_usrreq.c b/sys/netinet/tcp_usrreq.c index 7c791e0c4871..2dea7253e0d6 100644 --- a/sys/netinet/tcp_usrreq.c +++ b/sys/netinet/tcp_usrreq.c @@ -896,21 +896,20 @@ tcp_usr_shutdown(struct socket *so) struct epoch_tracker et; TCPDEBUG0; - NET_EPOCH_ENTER(et); inp = sotoinpcb(so); KASSERT(inp != NULL, ("inp == NULL")); INP_WLOCK(inp); - 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(); socantsendmore(so); tcp_usrclosed(tp); if (!(inp->inp_flags & INP_DROPPED)) error = tcp_output_nodrop(tp); -out: TCPDEBUG2(PRU_SHUTDOWN); TCP_PROBE2(debug__user, tp, PRU_SHUTDOWN); error = tcp_unlock_or_drop(tp, error); |