sock/ssl: don't free SSL_CTX on accept() failure

SSL_CTX isn't created in accept(), but when a socket on which accept()
is called is created, so it shouldn't be freed when accept() fails, as
this makes the socket unusable (any subsequent operations using SSL_CTX
would be using freed memory).

This caused the segfaults reported in issue #2681, where the second
connection would crash the application.

Signed-off-by: Konrad Sztyber <konrad.sztyber@intel.com>
Change-Id: I1a01a748c5a34ce3dd0fd3c557b860c0ff314b85
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/14355
Reviewed-by: Aleksey Marchuk <alexeymar@nvidia.com>
Reviewed-by: Shuhei Matsumoto <smatsumoto@nvidia.com>
Reviewed-by: Dong Yi <dongx.yi@intel.com>
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Mellanox Build Bot
This commit is contained in:
Konrad Sztyber 2022-09-05 04:25:45 +02:00 committed by Tomasz Zawadzki
parent f2ddc6e78b
commit a8a7edcd52

View File

@ -1050,7 +1050,6 @@ posix_sock_accept(struct spdk_sock *_sock)
if (!ssl) { if (!ssl) {
SPDK_ERRLOG("ssl_sock_accept_loop() failed, errno = %d\n", errno); SPDK_ERRLOG("ssl_sock_accept_loop() failed, errno = %d\n", errno);
close(fd); close(fd);
SSL_CTX_free(sock->ctx);
return NULL; return NULL;
} }
} }