git: 0af4ce45472c - main - tcp_usr_shutdown: don't cast inp_ppcb to tcpcb before checking inp_flags
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 28 Dec 2021 00:58:38 UTC
The branch main has been updated by glebius: URL: https://cgit.FreeBSD.org/src/commit/?id=0af4ce45472c3ddad8d1835815f5d09943fc7274 commit 0af4ce45472c3ddad8d1835815f5d09943fc7274 Author: Gleb Smirnoff <glebius@FreeBSD.org> AuthorDate: 2021-12-28 00:58:09 +0000 Commit: Gleb Smirnoff <glebius@FreeBSD.org> CommitDate: 2021-12-28 00:58:09 +0000 tcp_usr_shutdown: don't cast inp_ppcb to tcpcb before checking inp_flags Fixes: f64dc2ab5be38e5366271ef85ea90d8cb1c7841a --- sys/netinet/tcp_usrreq.c | 9 ++++----- 1 file 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);