Skip to content

Commit

Permalink
util: Check the return value of ofi_genlock_init()
Browse files Browse the repository at this point in the history
Signed-off-by: Jianxin Xiong <jianxin.xiong@intel.com>
  • Loading branch information
j-xiong committed Nov 3, 2023
1 parent aa4c337 commit 9037ad1
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
6 changes: 5 additions & 1 deletion prov/util/src/util_av.c
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,11 @@ int ofi_av_init_lightweight(struct util_domain *domain, const struct fi_av_attr
*/
av->context = context;
av->domain = domain;
ofi_genlock_init(&av->ep_list_lock, OFI_LOCK_MUTEX);

ret = ofi_genlock_init(&av->ep_list_lock, OFI_LOCK_MUTEX);
if (ret)
return ret;

dlist_init(&av->ep_list);
ofi_atomic_inc32(&domain->ref);
return 0;
Expand Down
14 changes: 11 additions & 3 deletions prov/util/src/util_cntr.c
Original file line number Diff line number Diff line change
Expand Up @@ -387,10 +387,13 @@ int ofi_cntr_init(const struct fi_provider *prov, struct fid_domain *domain,
} else {
ret = util_init_peer_cntr(cntr);
if (ret)
return ret;
goto errout_close_wait;
}

ofi_genlock_init(&cntr->ep_list_lock, OFI_LOCK_MUTEX);
ret = ofi_genlock_init(&cntr->ep_list_lock, OFI_LOCK_MUTEX);
if (ret)
goto errout_close_wait;

ofi_atomic_inc32(&cntr->domain->ref);

/* CNTR must be fully operational before adding to wait set */
Expand All @@ -400,9 +403,14 @@ int ofi_cntr_init(const struct fi_provider *prov, struct fid_domain *domain,
&cntr->cntr_fid.fid, 0);
if (ret) {
ofi_cntr_cleanup(cntr);
return ret;
goto errout_close_wait;
}
}

return 0;

errout_close_wait:
if (wait && attr->wait_obj != FI_WAIT_SET)
fi_close(&wait->fid);
return ret;
}

0 comments on commit 9037ad1

Please sign in to comment.