From 114a0677387ef743a219a8e66b43c3fdd8e885bc Mon Sep 17 00:00:00 2001 From: Jacek Kalwas Date: Fri, 12 Jul 2019 11:25:54 +0200 Subject: [PATCH] nvmf/rdma: pd null check In case of pd allocation by nvmf hooks there is a lack of null check as oposed to pd allocation by ibv_alloc_pd. Signed-off-by: Jacek Kalwas Change-Id: Iead6e0332bdee3da4adb6e657af298215c4e2196 Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/461576 Tested-by: SPDK CI Jenkins Reviewed-by: Darek Stojaczyk Reviewed-by: Shuhei Matsumoto Reviewed-by: Changpeng Liu --- lib/nvmf/rdma.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/lib/nvmf/rdma.c b/lib/nvmf/rdma.c index f8c0814de..9e3e2bfe8 100644 --- a/lib/nvmf/rdma.c +++ b/lib/nvmf/rdma.c @@ -2128,7 +2128,6 @@ spdk_nvmf_rdma_create(struct spdk_nvmf_transport_opts *opts) int rc; struct spdk_nvmf_rdma_transport *rtransport; struct spdk_nvmf_rdma_device *device, *tmp; - struct ibv_pd *pd; struct ibv_context **contexts; uint32_t i; int flag; @@ -2282,20 +2281,16 @@ spdk_nvmf_rdma_create(struct spdk_nvmf_transport_opts *opts) TAILQ_INSERT_TAIL(&rtransport->devices, device, link); i++; - pd = NULL; if (g_nvmf_hooks.get_ibv_pd) { - pd = g_nvmf_hooks.get_ibv_pd(NULL, device->context); + device->pd = g_nvmf_hooks.get_ibv_pd(NULL, device->context); + } else { + device->pd = ibv_alloc_pd(device->context); } - if (!g_nvmf_hooks.get_ibv_pd) { - device->pd = ibv_alloc_pd(device->context); - if (!device->pd) { - SPDK_ERRLOG("Unable to allocate protection domain.\n"); - spdk_nvmf_rdma_destroy(&rtransport->transport); - return NULL; - } - } else { - device->pd = pd; + if (!device->pd) { + SPDK_ERRLOG("Unable to allocate protection domain.\n"); + spdk_nvmf_rdma_destroy(&rtransport->transport); + return NULL; } assert(device->map == NULL);