git: 14fee5324a9b - main - tcp: improve failure handling in tcp_newtcpcb()
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Thu, 27 Jun 2024 17:56:14 UTC
The branch main has been updated by tuexen:
URL: https://cgit.FreeBSD.org/src/commit/?id=14fee5324a9b76fff6e8aad266600eefab3ef335
commit 14fee5324a9b76fff6e8aad266600eefab3ef335
Author: Michael Tuexen <tuexen@FreeBSD.org>
AuthorDate: 2024-06-27 06:26:34 +0000
Commit: Michael Tuexen <tuexen@FreeBSD.org>
CommitDate: 2024-06-27 06:26:34 +0000
tcp: improve failure handling in tcp_newtcpcb()
In case of a failure of tcp_newtcpcb, where NULL is returned,
* call CC_ALGO(tp)->cb_destroy, after CC_ALGO(tp)->cb_init was called.
* call khelp_destroy_osd(), after khelp_init_osd() was called.
Reviewed by: glebius, rscheff
MFC after: 1 week
Sponsored by: Netflix, Inc.
Differential Revision: https://reviews.freebsd.org/D45753
---
sys/netinet/tcp_subr.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/sys/netinet/tcp_subr.c b/sys/netinet/tcp_subr.c
index b871d8416b19..438c9cf899c6 100644
--- a/sys/netinet/tcp_subr.c
+++ b/sys/netinet/tcp_subr.c
@@ -2215,6 +2215,10 @@ tcp_newtcpcb(struct inpcb *inp)
#ifdef TCP_HHOOK
if (khelp_init_osd(HELPER_CLASS_TCP, &tp->t_osd)) {
+ if (CC_ALGO(tp)->cb_destroy != NULL)
+ CC_ALGO(tp)->cb_destroy(&tp->t_ccv);
+ CC_DATA(tp) = NULL;
+ cc_detach(tp);
if (tp->t_fb->tfb_tcp_fb_fini)
(*tp->t_fb->tfb_tcp_fb_fini)(tp, 1);
refcount_release(&tp->t_fb->tfb_refcnt);
@@ -2291,6 +2295,13 @@ tcp_newtcpcb(struct inpcb *inp)
tp->t_pacing_rate = -1;
if (tp->t_fb->tfb_tcp_fb_init) {
if ((*tp->t_fb->tfb_tcp_fb_init)(tp, &tp->t_fb_ptr)) {
+ if (CC_ALGO(tp)->cb_destroy != NULL)
+ CC_ALGO(tp)->cb_destroy(&tp->t_ccv);
+ CC_DATA(tp) = NULL;
+ cc_detach(tp);
+#ifdef TCP_HHOOK
+ khelp_destroy_osd(&tp->t_osd);
+#endif
refcount_release(&tp->t_fb->tfb_refcnt);
return (NULL);
}