diff options
author | John Levon <john.levon@nutanix.com> | 2021-03-22 16:58:14 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-22 16:58:14 +0000 |
commit | 8ba55dfb9bb54b773513e78d87d9ebe078384573 (patch) | |
tree | 271dd06dec57e1d0702251db1d6cc05fea27006b /lib/tran_sock.c | |
parent | 3c33c863a178dbb656c835a000df0defdbaa1a9d (diff) | |
download | libvfio-user-8ba55dfb9bb54b773513e78d87d9ebe078384573.zip libvfio-user-8ba55dfb9bb54b773513e78d87d9ebe078384573.tar.gz libvfio-user-8ba55dfb9bb54b773513e78d87d9ebe078384573.tar.bz2 |
fix vfu_ctx_create() error path (#393)
The ->detach() and ->fini() transport handlers can't presume ->tran_data is set,
since we cleanup a failed vfu_create_ctx() with vfu_destroy_ctx().
Signed-off-by: John Levon <john.levon@nutanix.com>
Reviewed-by: Swapnil Ingle <swapnil.ingle@nutanix.com>
Diffstat (limited to 'lib/tran_sock.c')
-rw-r--r-- | lib/tran_sock.c | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/lib/tran_sock.c b/lib/tran_sock.c index 51a8566..87072d6 100644 --- a/lib/tran_sock.c +++ b/lib/tran_sock.c @@ -848,11 +848,10 @@ tran_sock_detach(vfu_ctx_t *vfu_ctx) tran_sock_t *ts; assert(vfu_ctx != NULL); - assert(vfu_ctx->tran_data != NULL); ts = vfu_ctx->tran_data; - if (ts->conn_fd != -1) { + if (ts != NULL && ts->conn_fd != -1) { // FIXME: handle EINTR (void) close(ts->conn_fd); ts->conn_fd = -1; @@ -865,11 +864,10 @@ tran_sock_fini(vfu_ctx_t *vfu_ctx) tran_sock_t *ts; assert(vfu_ctx != NULL); - assert(vfu_ctx->tran_data != NULL); ts = vfu_ctx->tran_data; - if (ts->listen_fd != -1) { + if (ts != NULL && ts->listen_fd != -1) { // FIXME: handle EINTR (void) close(ts->listen_fd); ts->listen_fd = -1; |