Skip to content

Commit 075dfa4

Browse files
committed
topo/treematch: fix component coverity issues
Fix CID 1315298: Resource leak (RESOURCE_LEAK) : Fix CID 1315300: Resource leak (RESOURCE_LEAK): Fix CID 1315299: Resource leak (RESOURCE_LEAK): Fix CID 1315297 (#1 of 1): Resource leak (RESOURCE_LEAK): Confirmed leaks in error paths. Added the leaked arrays to the ERR_EXIT macro to ensure they are freed. Fix CID 1315296 (#1 of 1): Resource leak (RESOURCE_LEAK): Confirmed leak in error paths. Both the oversub and reqs arrays are leaked. Free these arrays on error. Signed-off-by: Nathan Hjelm <[email protected]>
1 parent 3540b65 commit 075dfa4

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

ompi/mca/topo/treematch/topo_treematch_dist_graph_create.c

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
12
/*
23
* Copyright (c) 2011-2015 The University of Tennessee and The University
34
* of Tennessee Research Foundation. All rights
@@ -7,6 +8,8 @@
78
* Copyright (c) 2015 Intel, Inc. All rights reserved
89
* Copyright (c) 2015 Research Organization for Information Science
910
* and Technology (RIST). All rights reserved.
11+
* Copyright (c) 2016 Los Alamos National Security, LLC. All rights
12+
* reserved.
1013
* $COPYRIGHT$
1114
*
1215
* Additional copyrights may follow
@@ -31,7 +34,12 @@
3134
#include "opal/mca/pmix/pmix.h"
3235

3336
#define ERR_EXIT(ERR) \
34-
do { free(local_pattern); \
37+
do { \
38+
free (nodes_roots); \
39+
free (local_procs); \
40+
free (tracker); \
41+
free (colors); \
42+
free(local_pattern); \
3543
return (ERR); } \
3644
while(0);
3745

@@ -70,12 +78,20 @@ static int check_oversubscribing(int rank,
7078
oversub[0] = local_oversub;
7179
for(i = 1; i < num_nodes; i++)
7280
if (OMPI_SUCCESS != ( err = MCA_PML_CALL(irecv(&oversub[i], 1, MPI_INT,
73-
nodes_roots[i], 111, comm_old, &reqs[i-1]))))
81+
nodes_roots[i], 111, comm_old, &reqs[i-1])))) {
82+
/* NTH: more needs to be done to correctly clean up here */
83+
free (reqs);
84+
free (oversub);
7485
return err;
86+
}
7587

7688
if (OMPI_SUCCESS != ( err = ompi_request_wait_all(num_nodes-1,
77-
reqs, MPI_STATUSES_IGNORE)))
89+
reqs, MPI_STATUSES_IGNORE))) {
90+
/* NTH: more needs to be done to correctly clean up here */
91+
free (reqs);
92+
free (oversub);
7893
return err;
94+
}
7995

8096
for(i = 0; i < num_nodes; i++)
8197
oversubscribed += oversub[i];

0 commit comments

Comments
 (0)