Skip to content

Commit c752534

Browse files
authored
Merge pull request #8316 from wzamazon/master_fix_btl_ofi_leak
btl/ofi: fix memory leaks in error handling path
2 parents 8ff2277 + 01f5d68 commit c752534

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

opal/mca/btl/ofi/btl_ofi_atomics.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,10 @@ int mca_btl_ofi_afop (struct mca_btl_base_module_t *btl, struct mca_btl_base_end
7373
fi_datatype, fi_op, &comp->comp_ctx);
7474

7575
if (rc == -FI_EAGAIN) {
76+
opal_free_list_return(comp->base.my_list, (opal_free_list_item_t*) comp);
7677
return OPAL_ERR_OUT_OF_RESOURCE;
7778
} else if (rc < 0) {
79+
opal_free_list_return(comp->base.my_list, (opal_free_list_item_t*) comp);
7880
BTL_ERROR(("fi_fetch_atomic failed with rc=%d (%s)", rc, fi_strerror(-rc)));
7981
MCA_BTL_OFI_ABORT();
8082
}
@@ -125,8 +127,10 @@ int mca_btl_ofi_aop (struct mca_btl_base_module_t *btl, mca_btl_base_endpoint_t
125127
fi_datatype, fi_op, &comp->comp_ctx);
126128

127129
if (rc == -FI_EAGAIN) {
130+
opal_free_list_return(comp->base.my_list, (opal_free_list_item_t*) comp);
128131
return OPAL_ERR_OUT_OF_RESOURCE;
129132
} else if (rc < 0) {
133+
opal_free_list_return(comp->base.my_list, (opal_free_list_item_t*) comp);
130134
BTL_ERROR(("fi_atomic failed with rc=%d (%s)", rc, fi_strerror(-rc)));
131135
MCA_BTL_OFI_ABORT();
132136
}
@@ -181,8 +185,10 @@ int mca_btl_ofi_acswap (struct mca_btl_base_module_t *btl, struct mca_btl_base_e
181185
&comp->comp_ctx);
182186

183187
if (rc == -FI_EAGAIN) {
188+
opal_free_list_return(comp->base.my_list, (opal_free_list_item_t*) comp);
184189
return OPAL_ERR_OUT_OF_RESOURCE;
185190
} else if (rc < 0) {
191+
opal_free_list_return(comp->base.my_list, (opal_free_list_item_t*) comp);
186192
BTL_ERROR(("fi_compare_atomic failed with rc=%d (%s)", rc, fi_strerror(-rc)));
187193
MCA_BTL_OFI_ABORT();
188194
}

opal/mca/btl/ofi/btl_ofi_rdma.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,12 @@ int mca_btl_ofi_get (mca_btl_base_module_t *btl, mca_btl_base_endpoint_t *endpoi
8888
&comp->comp_ctx); /* completion context */
8989

9090
if (-FI_EAGAIN == rc) {
91+
opal_free_list_return(comp->base.my_list, (opal_free_list_item_t*) comp);
9192
return OPAL_ERR_OUT_OF_RESOURCE;
9293
}
9394

9495
if (0 != rc) {
96+
opal_free_list_return(comp->base.my_list, (opal_free_list_item_t*) comp);
9597
BTL_ERROR(("fi_read failed with %d:%s", rc, fi_strerror(-rc)));
9698
MCA_BTL_OFI_ABORT();
9799
}
@@ -133,10 +135,12 @@ int mca_btl_ofi_put (mca_btl_base_module_t *btl, mca_btl_base_endpoint_t *endpoi
133135
&comp->comp_ctx); /* completion context */
134136

135137
if (-FI_EAGAIN == rc) {
138+
opal_free_list_return(comp->base.my_list, (opal_free_list_item_t*) comp);
136139
return OPAL_ERR_OUT_OF_RESOURCE;
137140
}
138141

139142
if (0 != rc) {
143+
opal_free_list_return(comp->base.my_list, (opal_free_list_item_t*) comp);
140144
BTL_ERROR(("fi_write failed with %d:%s", rc, fi_strerror(-rc)));
141145
MCA_BTL_OFI_ABORT();
142146
}

0 commit comments

Comments
 (0)