Skip to content

Commit f72b6d4

Browse files
committed
crs/none: fix coverity issues
CID 1301389 Resource leak (RESOURCE_LEAK) There is no conceivable reason to strdup cr_argv[0] in either location. Removed the calls to strdup. CID 741357 Resource leak (RESOURCE_LEAK) cr_argv was created by opal_argv_split (tmp_argv[0], ' '). Why should we call opal_argv_join (' ') on this array. Leak fixed by printing out tmp_argv[0] instead of calling opal_argv_join. CID 741358 Resource leak (RESOURCE_LEAK) The code does not handle exec failure correctly. The error should be communicated to the parent process but the function in question is only called by the parent. This calls into question some of the structure of the function in general (like what is the point of returning the child process id). That said, I will go ahead and add the opal_argv_free to quiet this error. Signed-off-by: Nathan Hjelm <[email protected]>
1 parent 7e34997 commit f72b6d4

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

opal/mca/crs/none/crs_none_module.c

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1+
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
12
/*
23
* Copyright (c) 2004-2010 The Trustees of Indiana University.
34
* All rights reserved.
45
*
56
* Copyright (c) 2015 Cisco Systems, Inc. All rights reserved.
7+
* Copyright (c) 2015 Los Alamos National Security, LLC. All rights
8+
* reserved.
69
* $COPYRIGHT$
710
*
811
* Additional copyrights may follow
@@ -101,8 +104,7 @@ int opal_crs_none_restart(opal_crs_base_snapshot_t *base_snapshot, bool spawn_ch
101104
opal_output(0,
102105
"crs:none: checkpoint(): Error: Unable to open the file (%s)",
103106
base_snapshot->metadata_filename);
104-
exit_status = OPAL_ERROR;
105-
goto cleanup;
107+
return OPAL_ERROR;
106108
}
107109
}
108110

@@ -131,10 +133,9 @@ int opal_crs_none_restart(opal_crs_base_snapshot_t *base_snapshot, bool spawn_ch
131133
if( !spawn_child ) {
132134
opal_output_verbose(10, opal_crs_base_framework.framework_output,
133135
"crs:none: none_restart: exec :(%s, %s):",
134-
strdup(cr_argv[0]),
135-
opal_argv_join(cr_argv, ' '));
136+
cr_argv[0], tmp_argv[0]);
136137

137-
status = execvp(strdup(cr_argv[0]), cr_argv);
138+
status = execvp(cr_argv[0], cr_argv);
138139

139140
if(status < 0) {
140141
opal_output(opal_crs_base_framework.framework_output,
@@ -152,10 +153,11 @@ int opal_crs_none_restart(opal_crs_base_snapshot_t *base_snapshot, bool spawn_ch
152153
}
153154

154155
cleanup:
155-
if (NULL != base_snapshot->metadata) {
156-
fclose(base_snapshot->metadata);
156+
if (cr_argv) {
157+
opal_argv_free (cr_argv);
157158
}
158-
base_snapshot->metadata = NULL;
159+
160+
fclose(base_snapshot->metadata);
159161

160162
return exit_status;
161163
}

0 commit comments

Comments
 (0)