Skip to content

Commit b9e4c41

Browse files
authored
Merge pull request #10634 from AboorvaDevarajan/fix_osc_rdma
osc/rdma: fix data integrity issue in rdma get_accumulate
2 parents c2eeca8 + 02d2f5c commit b9e4c41

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

ompi/mca/osc/rdma/osc_rdma_accumulate.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -272,13 +272,14 @@ static inline int ompi_osc_rdma_gacc_amo (ompi_osc_rdma_module_t *module, ompi_o
272272
{
273273
const bool use_amo = module->acc_use_amo;
274274
const size_t dt_size = datatype->super.size;
275+
void *result_start = result;
275276
void *to_free = NULL;
276277
int ret;
277278

278279
OSC_RDMA_VERBOSE(MCA_BASE_VERBOSE_TRACE, "using network atomics for accumulate operation with count %d", count);
279280

280281
if (NULL == result) {
281-
to_free = result = malloc (request->len);
282+
to_free = result_start = result = malloc (request->len);
282283
if (OPAL_UNLIKELY(NULL == result)) {
283284
return OMPI_ERR_OUT_OF_RESOURCE;
284285
}
@@ -307,14 +308,15 @@ static inline int ompi_osc_rdma_gacc_amo (ompi_osc_rdma_module_t *module, ompi_o
307308
target_address += dt_size;
308309
++i;
309310
} else if (OPAL_UNLIKELY(OMPI_ERR_NOT_SUPPORTED == ret)) {
311+
free(to_free);
310312
return OMPI_ERR_NOT_SUPPORTED;
311313
}
312314
}
313315

314316
if (NULL != result_convertor) {
315317
/* result buffer is not necessarily contiguous. use the opal datatype engine to
316318
* copy the data over in this case */
317-
struct iovec iov = {.iov_base = result, .iov_len = request->len};
319+
struct iovec iov = {.iov_base = result_start, .iov_len = request->len};
318320
uint32_t iov_count = 1;
319321
size_t size = request->len;
320322

0 commit comments

Comments
 (0)