diff --git a/ompi/mca/btl/openib/btl_openib.c b/ompi/mca/btl/openib/btl_openib.c index e247a34cb3..071de6b7b9 100644 --- a/ompi/mca/btl/openib/btl_openib.c +++ b/ompi/mca/btl/openib/btl_openib.c @@ -1409,25 +1409,27 @@ static int mca_btl_openib_finalize_resources(struct mca_btl_base_module_t* btl) } /* Release all QPs */ - for (ep_index=0; - ep_index < opal_pointer_array_get_size(openib_btl->device->endpoints); - ep_index++) { - endpoint=(mca_btl_openib_endpoint_t *)opal_pointer_array_get_item(openib_btl->device->endpoints, - ep_index); - if(!endpoint) { - BTL_VERBOSE(("In finalize, got another null endpoint")); - continue; - } - if(endpoint->endpoint_btl != openib_btl) { - continue; - } - for(i = 0; i < openib_btl->device->eager_rdma_buffers_count; i++) { - if(openib_btl->device->eager_rdma_buffers[i] == endpoint) { - openib_btl->device->eager_rdma_buffers[i] = NULL; - OBJ_RELEASE(endpoint); + if (NULL != openib_btl->device->endpoints) { + for (ep_index=0; + ep_index < opal_pointer_array_get_size(openib_btl->device->endpoints); + ep_index++) { + endpoint=(mca_btl_openib_endpoint_t *)opal_pointer_array_get_item(openib_btl->device->endpoints, + ep_index); + if(!endpoint) { + BTL_VERBOSE(("In finalize, got another null endpoint")); + continue; } + if(endpoint->endpoint_btl != openib_btl) { + continue; + } + for(i = 0; i < openib_btl->device->eager_rdma_buffers_count; i++) { + if(openib_btl->device->eager_rdma_buffers[i] == endpoint) { + openib_btl->device->eager_rdma_buffers[i] = NULL; + OBJ_RELEASE(endpoint); + } + } + OBJ_RELEASE(endpoint); } - OBJ_RELEASE(endpoint); } /* Release SRQ resources */ diff --git a/ompi/mca/btl/openib/btl_openib_component.c b/ompi/mca/btl/openib/btl_openib_component.c index 66c7edd296..05c0e4840b 100644 --- a/ompi/mca/btl/openib/btl_openib_component.c +++ b/ompi/mca/btl/openib/btl_openib_component.c @@ -775,7 +775,7 @@ static int init_one_port(opal_list_t *btl_list, mca_btl_openib_device_t *device, for(i = 0; i < mca_btl_openib_component.btls_per_lid; i++){ char param[40]; - openib_btl = (mca_btl_openib_module_t *) malloc(sizeof(mca_btl_openib_module_t)); + openib_btl = (mca_btl_openib_module_t *) calloc(1, sizeof(mca_btl_openib_module_t)); if(NULL == openib_btl) { BTL_ERROR(("Failed malloc: %s:%d", __FILE__, __LINE__)); return OMPI_ERR_OUT_OF_RESOURCE; @@ -873,6 +873,8 @@ static void device_construct(mca_btl_openib_device_t *device) device->ib_channel = NULL; #endif device->btls = 0; + device->endpoints = NULL; + device->device_btls = NULL; device->ib_cq[BTL_OPENIB_HP_CQ] = NULL; device->ib_cq[BTL_OPENIB_LP_CQ] = NULL; device->cq_size[BTL_OPENIB_HP_CQ] = 0;