From 3703e1a73e0e0367c04f47f793e46495e46e647b Mon Sep 17 00:00:00 2001 From: Michael Tuexen Date: Thu, 27 Jun 2024 07:25:15 +0200 Subject: [PATCH] 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 --- sys/netinet/tcp_syncache.c | 1 + 1 file changed, 1 insertion(+) diff --git a/sys/netinet/tcp_syncache.c b/sys/netinet/tcp_syncache.c index c21dbbb58e31..1a3b6ebf6788 100644 --- a/sys/netinet/tcp_syncache.c +++ b/sys/netinet/tcp_syncache.c @@ -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))) {