Skip to content

Commit 8d88c61

Browse files
opal: Segfault avoidance 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 <[email protected]> (cherry picked from commit 26d0201)
1 parent 1c67bf1 commit 8d88c61

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
@@ -675,8 +675,10 @@ static int mca_btl_ofi_init_device(struct fi_info *info)
675675

676676
/* if the contexts have not been initiated, num_contexts should
677677
* be zero and we skip this. */
678-
for (int i=0; i < module->num_contexts; i++) {
679-
mca_btl_ofi_context_finalize(&module->contexts[i], module->is_scalable_ep);
678+
if (NULL != module->contexts) {
679+
for (int i = 0; i < module->num_contexts; i++) {
680+
mca_btl_ofi_context_finalize(&module->contexts[i], module->is_scalable_ep);
681+
}
680682
}
681683
free(module->contexts);
682684

opal/mca/btl/ofi/btl_ofi_context.c

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

328328
/* Can we destruct the object that hasn't been constructed? */
329-
OBJ_DESTRUCT(&context->rdma_comp_list);
329+
if (context->rdma_comp_list.fl_num_allocated != 0){
330+
OBJ_DESTRUCT(&context->rdma_comp_list);
331+
}
330332

331333
if (TWO_SIDED_ENABLED) {
332334
OBJ_DESTRUCT(&context->frag_comp_list);

0 commit comments

Comments
 (0)