summaryrefslogtreecommitdiffstats
path: root/src/vnet
diff options
context:
space:
mode:
authorXiaoming Jiang <jiangxiaoming@outlook.com>2023-05-26 00:32:25 +0000
committerXiaoming Jiang <jiangxiaoming@outlook.com>2023-05-26 00:32:25 +0000
commit4778164869395ec9efeeef31fc08f97b93cdff90 (patch)
tree26f58044bd14e2cc1b13b68c4d5752ba58e6e79d /src/vnet
parentd921b8988044f708318eb73a1fa883fce094a4d6 (diff)
tls: fix memory leak when client/server init error
Type: fix Signed-off-by: Xiaoming Jiang <jiangxiaoming@outlook.com> Change-Id: I484f3759b6c27052e08741398ec389729285f035
Diffstat (limited to 'src/vnet')
-rw-r--r--src/vnet/tls/tls.c20
1 files changed, 18 insertions, 2 deletions
diff --git a/src/vnet/tls/tls.c b/src/vnet/tls/tls.c
index b082467c95f..fb625c841c6 100644
--- a/src/vnet/tls/tls.c
+++ b/src/vnet/tls/tls.c
@@ -463,6 +463,7 @@ tls_session_accept_callback (session_t * tls_session)
session_t *tls_listener, *app_session;
tls_ctx_t *lctx, *ctx;
u32 ctx_handle;
+ int rv;
tls_listener =
listen_session_get_from_handle (tls_session->listener_handle);
@@ -489,7 +490,14 @@ tls_session_accept_callback (session_t * tls_session)
TLS_DBG (1, "Accept on listener %u new connection [%u]%x",
tls_listener->opaque, vlib_get_thread_index (), ctx_handle);
- return tls_ctx_init_server (ctx);
+ rv = tls_ctx_init_server (ctx);
+ if (rv)
+ {
+ session_free (app_session);
+ tls_ctx_free (ctx);
+ }
+
+ return rv;
}
int
@@ -530,6 +538,7 @@ tls_session_connected_cb (u32 tls_app_index, u32 ho_ctx_index,
tls_ctx_t *ho_ctx, *ctx;
session_type_t st;
u32 ctx_handle;
+ int rv;
ho_ctx = tls_ctx_half_open_get (ho_ctx_index);
@@ -559,7 +568,14 @@ tls_session_connected_cb (u32 tls_app_index, u32 ho_ctx_index,
app_session->session_type = st;
app_session->connection_index = ctx->tls_ctx_handle;
- return tls_ctx_init_client (ctx);
+ rv = tls_ctx_init_client (ctx);
+ if (rv)
+ {
+ session_free (app_session);
+ tls_ctx_free (ctx);
+ }
+
+ return rv;
}
int