From 35a71c7748c7ca8fd5bee13b18cb290f533f7dd6 Mon Sep 17 00:00:00 2001 From: Konrad Sztyber Date: Wed, 14 Sep 2022 09:37:10 +0200 Subject: [PATCH] sock/ssl: free SSL resources in case of failures Signed-off-by: Konrad Sztyber Change-Id: Ifba581c92269c675b03b67586b1fea0b096f9e95 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/14511 Tested-by: SPDK CI Jenkins Reviewed-by: Krzysztof Karas Reviewed-by: Jim Harris Reviewed-by: Tomasz Zawadzki --- module/sock/posix/posix.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/module/sock/posix/posix.c b/module/sock/posix/posix.c index 1883621ef..934a33b27 100644 --- a/module/sock/posix/posix.c +++ b/module/sock/posix/posix.c @@ -948,6 +948,8 @@ retry: flag = fcntl(fd, F_GETFL); if (fcntl(fd, F_SETFL, flag | O_NONBLOCK) < 0) { SPDK_ERRLOG("fcntl can't set nonblocking mode for socket, fd: %d (%d)\n", fd, errno); + SSL_free(ssl); + SSL_CTX_free(ctx); close(fd); fd = -1; break; @@ -966,6 +968,8 @@ retry: sock = posix_sock_alloc(fd, &impl_opts, enable_zcopy_user_opts && enable_zcopy_impl_opts); if (sock == NULL) { SPDK_ERRLOG("sock allocation failed\n"); + SSL_free(ssl); + SSL_CTX_free(ctx); close(fd); return NULL; }