Skip to content

Commit 8f538d7

Browse files
v4.1.x: opal Segfault avoidence in class and mca/btl/ofi
Fixed a loop causing segfaults in opal_object.h 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>
1 parent 34123c3 commit 8f538d7

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

opal/class/opal_object.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,7 @@ static inline void opal_obj_run_destructors(opal_object_t * object)
479479
assert(NULL != object->obj_class);
480480

481481
cls_destruct = object->obj_class->cls_destruct_array;
482-
while( NULL != *cls_destruct ) {
482+
while( cls_destruct ) {
483483
(*cls_destruct)(object);
484484
cls_destruct++;
485485
}

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 (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

0 commit comments

Comments
 (0)