diff --git a/sys/netinet/tcp_syncache.c b/sys/netinet/tcp_syncache.c --- a/sys/netinet/tcp_syncache.c +++ b/sys/netinet/tcp_syncache.c @@ -1375,7 +1375,6 @@ struct label *maclabel = NULL; #endif struct syncache scs; - struct ucred *cred; uint64_t tfo_response_cookie; unsigned int *tfo_pending = NULL; int tfo_cookie_valid = 0; @@ -1392,7 +1391,6 @@ */ KASSERT(SOLISTENING(so), ("%s: %p not listening", __func__, so)); tp = sototcpcb(so); - cred = V_tcp_syncache.see_other ? NULL : crhold(so->so_cred); #ifdef INET6 if (inc->inc_flags & INC_ISIPV6) { @@ -1623,9 +1621,11 @@ #ifdef MAC sc->sc_label = maclabel; #endif - sc->sc_cred = cred; + if (sc != &scs && !V_tcp_syncache.see_other) + sc->sc_cred = crhold(so->so_cred); + else + sc->sc_cred = NULL; sc->sc_port = port; - cred = NULL; sc->sc_ipopts = ipopts; bcopy(inc, &sc->sc_inc, sizeof(struct in_conninfo)); sc->sc_ip_tos = ip_tos; @@ -1761,8 +1761,6 @@ tcp_fastopen_decrement_counter(tfo_pending); tfo_expanded: - if (cred != NULL) - crfree(cred); if (sc == NULL || sc == &scs) { #ifdef MAC mac_syncache_destroy(&maclabel);