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 @@ -1559,6 +1559,7 @@ if (sc->sc_ipopts) (void)m_free(sc->sc_ipopts); sc->sc_ipopts = ipopts; + ipopts = NULL; } /* * Update timestamp if present. @@ -1673,6 +1674,7 @@ sc->sc_cred = NULL; sc->sc_port = port; sc->sc_ipopts = ipopts; + ipopts = NULL; bcopy(inc, &sc->sc_inc, sizeof(struct in_conninfo)); sc->sc_ip_tos = ip_tos; sc->sc_ip_ttl = ip_ttl; @@ -1819,13 +1821,14 @@ tfo_expanded: if (cred != NULL) crfree(cred); - if (sc == NULL || sc == &scs) { #ifdef MAC + if (sc == NULL || sc == &scs) mac_syncache_destroy(&maclabel); #endif - if (ipopts) - (void)m_free(ipopts); - } + if (sc == &scs) + ipopts = sc->sc_ipopts; + if (ipopts != NULL) + (void)m_free(ipopts); return (rv); }