sock/ssl: free SSL resources in case of failures

Signed-off-by: Konrad Sztyber <konrad.sztyber@intel.com>
Change-Id: Ifba581c92269c675b03b67586b1fea0b096f9e95
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/14511
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Krzysztof Karas <krzysztof.karas@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
This commit is contained in:
Konrad Sztyber 2022-09-14 09:37:10 +02:00 committed by Tomasz Zawadzki
parent 488d6e84c4
commit 35a71c7748

View File

@ -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;
}