Skip to content

Commit

Permalink
opal: Segfault avoidence in class and mca/btl/ofi
Browse files Browse the repository at this point in the history
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.com>
  • Loading branch information
joshfisher-cornelisnetworks committed Jun 10, 2022
1 parent 34123c3 commit ad9d9bc
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion opal/class/opal_object.h
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ static inline void opal_obj_run_destructors(opal_object_t * object)
assert(NULL != object->obj_class);

cls_destruct = object->obj_class->cls_destruct_array;
while( NULL != *cls_destruct ) {
while (NULL != cls_destruct && NULL != *cls_destruct) {
(*cls_destruct)(object);
cls_destruct++;
}
Expand Down
6 changes: 4 additions & 2 deletions opal/mca/btl/ofi/btl_ofi_component.c
Original file line number Diff line number Diff line change
Expand Up @@ -675,8 +675,10 @@ static int mca_btl_ofi_init_device(struct fi_info *info)

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

Expand Down

0 comments on commit ad9d9bc

Please sign in to comment.