Skip to content

Commit 26d0201

Browse files
opal: Segfault avoidence in mca/btl/ofi
Added a check before destructing rdma_comp_list and fixed goto fail block to check for NULL before potential dereference as we go there for NULL in what we dereference Signed-off-by: Josh Fisher <josh.fisher@cornelisnetworks.com>
1 parent c2a3016 commit 26d0201

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

opal/mca/btl/ofi/btl_ofi_component.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -625,8 +625,10 @@ static int mca_btl_ofi_init_device(struct fi_info *info)
625625

626626
/* if the contexts have not been initiated, num_contexts should
627627
* be zero and we skip this. */
628-
for (int i = 0; i < module->num_contexts; i++) {
629-
mca_btl_ofi_context_finalize(&module->contexts[i], module->is_scalable_ep);
628+
if (NULL != module->contexts) {
629+
for (int i = 0; i < module->num_contexts; i++) {
630+
mca_btl_ofi_context_finalize(&module->contexts[i], module->is_scalable_ep);
631+
}
630632
}
631633
free(module->contexts);
632634

opal/mca/btl/ofi/btl_ofi_context.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,9 @@ void mca_btl_ofi_context_finalize(mca_btl_ofi_context_t *context, bool scalable_
264264
}
265265

266266
/* Can we destruct the object that hasn't been constructed? */
267-
OBJ_DESTRUCT(&context->rdma_comp_list);
267+
if (context->rdma_comp_list.fl_num_allocated != 0){
268+
OBJ_DESTRUCT(&context->rdma_comp_list);
269+
}
268270

269271
if (TWO_SIDED_ENABLED) {
270272
OBJ_DESTRUCT(&context->frag_comp_list);

0 commit comments

Comments
 (0)