Skip to content

Commit

Permalink
Fix for Coverity CID 1357152.
Browse files Browse the repository at this point in the history
Or at least that was the origin of the issue. It turns out
we were freeing the wrong buffer (but as it only happen in the
case of an error we never noticed).
  • Loading branch information
bosilca committed Mar 24, 2016
1 parent ab8008e commit 57eadb0
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions ompi/mca/coll/base/coll_base_alltoall.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ mca_coll_base_alltoall_intra_basic_inplace(const void *rbuf, int rcount,
int i, j, size, rank, err = MPI_SUCCESS, line;
OPAL_PTRDIFF_TYPE ext, gap;
ompi_request_t **preq, **reqs;
char *tmp_buffer;
char *allocated_buffer = NULL, *tmp_buffer;
size_t max_size;

/* Initialize. */
Expand All @@ -67,9 +67,9 @@ mca_coll_base_alltoall_intra_basic_inplace(const void *rbuf, int rcount,
if( NULL == reqs ) { err = OMPI_ERR_OUT_OF_RESOURCE; line = __LINE__; goto error_hndl; }

/* Allocate a temporary buffer */
tmp_buffer = calloc (max_size, 1);
if (NULL == tmp_buffer) { return OMPI_ERR_OUT_OF_RESOURCE; }
tmp_buffer -= gap;
allocated_buffer = calloc (max_size, 1);
if( NULL == allocated_buffer) { err = OMPI_ERR_OUT_OF_RESOURCE; line = __LINE__; goto error_hndl; }
tmp_buffer = allocated_buffer - gap;
max_size = ext * rcount;

/* in-place alltoall slow algorithm (but works) */
Expand Down Expand Up @@ -119,7 +119,8 @@ mca_coll_base_alltoall_intra_basic_inplace(const void *rbuf, int rcount,

error_hndl:
/* Free the temporary buffer */
free (tmp_buffer);
if( NULL != allocated_buffer )
free (allocated_buffer);

if( MPI_SUCCESS != err ) {
OPAL_OUTPUT((ompi_coll_base_framework.framework_output,
Expand Down

0 comments on commit 57eadb0

Please sign in to comment.