From 579a2d10cc02de69b4917d60764cfb87e7bb59ed Mon Sep 17 00:00:00 2001 From: Nathan Hjelm Date: Fri, 7 Mar 2014 21:16:20 +0000 Subject: [PATCH] bcol/ptpcoll: initialize all pointers in the module to NULL to avoid possible problems when the module is being destructed. References #4331 cmr=v1.7.5:reviewer=manjugv This commit was SVN r30964. --- ompi/mca/bcol/ptpcoll/bcol_ptpcoll_module.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/ompi/mca/bcol/ptpcoll/bcol_ptpcoll_module.c b/ompi/mca/bcol/ptpcoll/bcol_ptpcoll_module.c index de12ff568b..378f4fa838 100644 --- a/ompi/mca/bcol/ptpcoll/bcol_ptpcoll_module.c +++ b/ompi/mca/bcol/ptpcoll/bcol_ptpcoll_module.c @@ -2,7 +2,7 @@ /* * Copyright (c) 2009-2013 Oak Ridge National Laboratory. All rights reserved. * Copyright (c) 2009-2012 Mellanox Technologies. All rights reserved. - * Copyright (c) 2012-2013 Los Alamos National Security, LLC. All rights + * Copyright (c) 2012-2014 Los Alamos National Security, LLC. All rights * reserved. * $COPYRIGHT$ * @@ -49,22 +49,21 @@ static int alloc_allreduce_offsets_array(mca_bcol_ptpcoll_module_t *ptpcoll_modu /* Precalculate the allreduce offsets */ if (0 < k_node->n_exchanges) { - ptpcoll_module->allgather_offsets = (int **)malloc(n_exchanges * sizeof(int*)); + ptpcoll_module->allgather_offsets = (int **) calloc (n_exchanges, sizeof(int *)); if (!ptpcoll_module->allgather_offsets) { - rc = OMPI_ERROR; - return rc; + return OMPI_ERROR; } - for (i=0; i < n_exchanges ; i++) { - ptpcoll_module->allgather_offsets[i] = (int *)malloc (sizeof(int) * NOFFSETS); + for (i = 0; i < n_exchanges ; i++) { + ptpcoll_module->allgather_offsets[i] = (int *) calloc (NOFFSETS, sizeof(int)); if (!ptpcoll_module->allgather_offsets[i]){ - rc = OMPI_ERROR; - return rc; + return OMPI_ERROR; } } } + return rc; } @@ -81,6 +80,7 @@ static int free_allreduce_offsets_array(mca_bcol_ptpcoll_module_t *ptpcoll_modul } free(ptpcoll_module->allgather_offsets); + ptpcoll_module->allgather_offsets = NULL; return rc; } @@ -89,6 +89,8 @@ mca_bcol_ptpcoll_module_construct(mca_bcol_ptpcoll_module_t *ptpcoll_module) { uint64_t i; /* Pointer to component */ + ptpcoll_module->narray_node = NULL; + ptpcoll_module->allgather_offsets = NULL; ptpcoll_module->super.bcol_component = (mca_bcol_base_component_t *) &mca_bcol_ptpcoll_component; ptpcoll_module->super.list_n_connected = NULL; ptpcoll_module->super.hier_scather_offset = 0; @@ -125,6 +127,7 @@ mca_bcol_ptpcoll_module_destruct(mca_bcol_ptpcoll_module_t *ptpcoll_module) } /* release the buffer descriptor */ free(ml_mem->ml_buf_desc); + ml_mem->ml_buf_desc = NULL; } if (NULL != ptpcoll_module->allgather_offsets) { @@ -139,6 +142,7 @@ mca_bcol_ptpcoll_module_destruct(mca_bcol_ptpcoll_module_t *ptpcoll_module) } free(ptpcoll_module->narray_node); + ptpcoll_module->narray_node = NULL; } OBJ_DESTRUCT(&ptpcoll_module->collreqs_free);