Skip to content

Commit 92a9667

Browse files
author
rhc54
committed
Merge pull request open-mpi#954 from ggouaillardet/topic/v1.10/osc_empty_group
osc/pt2pt: fix zero size malloc
2 parents 5af848c + 9187d08 commit 92a9667

File tree

1 file changed

+18
-12
lines changed

1 file changed

+18
-12
lines changed

ompi/mca/osc/pt2pt/osc_pt2pt_active_target.c

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
* reserved.
1313
* Copyright (c) 2010 IBM Corporation. All rights reserved.
1414
* Copyright (c) 2012-2013 Sandia National Laboratories. All rights reserved.
15-
* Copyright (c) 2015 Research Organization for Information Science
15+
* Copyright (c) 2015-2016 Research Organization for Information Science
1616
* and Technology (RIST). All rights reserved.
1717
* $COPYRIGHT$
1818
*
@@ -213,15 +213,17 @@ ompi_osc_pt2pt_start(ompi_group_t *group,
213213
"ompi_osc_pt2pt_start entering with group size %d...",
214214
group_size));
215215

216-
ranks = get_comm_ranks(module, module->sc_group);
217-
if (NULL == ranks) return OMPI_ERR_TEMP_OUT_OF_RESOURCE;
216+
if (OPAL_LIKELY(0 < group_size)) {
217+
ranks = get_comm_ranks(module, module->sc_group);
218+
if (NULL == ranks) return OMPI_ERR_TEMP_OUT_OF_RESOURCE;
218219

219-
for (int i = 0 ; i < group_size ; ++i) {
220-
/* when the post comes in we will be in an access epoch with this proc */
221-
module->peers[ranks[i]].access_epoch = true;
220+
for (int i = 0 ; i < group_size ; ++i) {
221+
/* when the post comes in we will be in an access epoch with this proc */
222+
module->peers[ranks[i]].access_epoch = true;
223+
}
224+
free (ranks);
222225
}
223226

224-
free (ranks);
225227

226228
OPAL_LIST_FOREACH_SAFE(pending_post, next, &module->pending_posts, ompi_osc_pt2pt_pending_post_t) {
227229
ompi_proc_t *pending_proc = ompi_comm_peer_lookup (module->comm, pending_post->rank);
@@ -284,8 +286,10 @@ ompi_osc_pt2pt_complete(ompi_win_t *win)
284286
return OMPI_ERR_RMA_SYNC;
285287
}
286288

287-
ranks = get_comm_ranks(module, module->sc_group);
288-
if (NULL == ranks) return OMPI_ERR_TEMP_OUT_OF_RESOURCE;
289+
if (OPAL_LIKELY(0 < ompi_group_size(module->sc_group))) {
290+
ranks = get_comm_ranks(module, module->sc_group);
291+
if (NULL == ranks) return OMPI_ERR_TEMP_OUT_OF_RESOURCE;
292+
}
289293

290294
OPAL_THREAD_LOCK(&module->lock);
291295

@@ -375,9 +379,7 @@ ompi_osc_pt2pt_complete(ompi_win_t *win)
375379

376380
OPAL_OUTPUT_VERBOSE((50, ompi_osc_base_framework.framework_output,
377381
"ompi_osc_pt2pt_complete complete"));
378-
free (ranks);
379-
380-
return OMPI_SUCCESS;
382+
ret = OMPI_SUCCESS;
381383

382384
cleanup:
383385
if (NULL != ranks) free(ranks);
@@ -428,6 +430,10 @@ ompi_osc_pt2pt_post(ompi_group_t *group,
428430
OPAL_OUTPUT_VERBOSE((50, ompi_osc_base_framework.framework_output,
429431
"sending post messages"));
430432

433+
if (OPAL_UNLIKELY(0 == ompi_group_size(module->pw_group))) {
434+
return OMPI_SUCCESS;
435+
}
436+
431437
ranks = get_comm_ranks(module, module->pw_group);
432438
if (NULL == ranks) {
433439
return OMPI_ERR_OUT_OF_RESOURCE;

0 commit comments

Comments
 (0)