From a0246f6553391380959eec4369cfbe2e0369dc04 Mon Sep 17 00:00:00 2001 From: shahar salzman Date: Wed, 4 Jul 2018 11:56:05 +0300 Subject: [PATCH] lib: validate ib_verbs context is valid before using it Change-Id: I54793624e46a4e51b0c989ddfe933ccb5f035123 Signed-off-by: shahar salzman Reviewed-on: https://review.gerrithub.io/417858 Tested-by: SPDK Automated Test System Reviewed-by: Daniel Verkamp Reviewed-by: Ben Walker --- lib/nvmf/rdma.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/nvmf/rdma.c b/lib/nvmf/rdma.c index 235ae7194..b04ad5ef8 100644 --- a/lib/nvmf/rdma.c +++ b/lib/nvmf/rdma.c @@ -1487,6 +1487,14 @@ spdk_nvmf_rdma_listen(struct spdk_nvmf_transport *transport, return rc; } + if (!port->id->verbs) { + SPDK_ERRLOG("ibv_context is null\n"); + rdma_destroy_id(port->id); + free(port); + pthread_mutex_unlock(&rtransport->lock); + return -1; + } + rc = rdma_listen(port->id, 10); /* 10 = backlog */ if (rc < 0) { SPDK_ERRLOG("rdma_listen() failed\n");