tcp: improve error handling in syncache_socket()

If syncache_socket() fails after calling tcp_newtcpcb(), the resources
allocated in tcp_newtcpcb() needs to be freed. Just call
tcp_discardcb() to do this.
Thanks to jtl for making me aware of the issue and proposing a fix.
Reviewed by:		glebius, jtl, rscheff
MFC after:		1 week
Sponsored by:		Netflix, Inc.
Differential Revision:	https://reviews.freebsd.org/D45749
This commit is contained in:
Michael Tuexen 2024-06-27 07:25:15 +02:00
parent 18a27dd641
commit 3703e1a73e

View File

@ -1053,6 +1053,7 @@ syncache_socket(struct syncache *sc, struct socket *lso, struct mbuf *m)
return (NULL);
abort:
tcp_discardcb(tp);
in_pcbfree(inp);
sodealloc(so);
if ((s = tcp_log_addrs(&sc->sc_inc, NULL, NULL, NULL))) {