1
1
as reported by Coverity with CIDs 70845, 71855, 710652,
1196738, 1196739, 1196757, 1196758, 1269863 and 1269883
Этот коммит содержится в:
Gilles Gouaillardet 2015-03-02 20:06:27 +09:00
родитель 4e7b5240e4
Коммит 89806c6261
3 изменённых файлов: 24 добавлений и 12 удалений

Просмотреть файл

@ -11,6 +11,8 @@
* All rights reserved. * All rights reserved.
* Copyright (c) 2013 Cisco Systems, Inc. All rights reserved. * Copyright (c) 2013 Cisco Systems, Inc. All rights reserved.
* Copyright (c) 2014 Intel, Inc. All rights reserved. * Copyright (c) 2014 Intel, Inc. All rights reserved.
* Copyright (c) 2015 Research Organization for Information Science
* and Technology (RIST). All rights reserved.
* $COPYRIGHT$ * $COPYRIGHT$
* *
* Additional copyrights may follow * Additional copyrights may follow
@ -74,12 +76,15 @@ int orte_util_add_dash_host_nodes(opal_list_t *nodes,
rc = opal_argv_append_nosize(&mapped_nodes, rc = opal_argv_append_nosize(&mapped_nodes,
mini_map[k]); mini_map[k]);
if (OPAL_SUCCESS != rc) { if (OPAL_SUCCESS != rc) {
opal_argv_free(host_argv);
opal_argv_free(mini_map);
goto cleanup; goto cleanup;
} }
} }
opal_argv_free(mini_map); opal_argv_free(mini_map);
} }
} }
opal_argv_free(host_argv);
/* Did we find anything? If not, then do nothing */ /* Did we find anything? If not, then do nothing */
if (NULL == mapped_nodes) { if (NULL == mapped_nodes) {
@ -201,9 +206,6 @@ int orte_util_add_dash_host_nodes(opal_list_t *nodes,
if (NULL != mapped_nodes) { if (NULL != mapped_nodes) {
opal_argv_free(mapped_nodes); opal_argv_free(mapped_nodes);
} }
if (NULL != host_argv) {
opal_argv_free(host_argv);
}
OPAL_LIST_DESTRUCT(&adds); OPAL_LIST_DESTRUCT(&adds);
return rc; return rc;

Просмотреть файл

@ -10,6 +10,8 @@
* University of Stuttgart. All rights reserved. * University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California. * Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved. * All rights reserved.
* Copyright (c) 2015 Research Organization for Information Science
* and Technology (RIST). All rights reserved.
* $COPYRIGHT$ * $COPYRIGHT$
* *
* Additional copyrights may follow * Additional copyrights may follow
@ -74,6 +76,11 @@ int orte_write_hnp_contact_file(char *filename)
FILE *fp; FILE *fp;
char *my_uri; char *my_uri;
my_uri = orte_rml.get_contact_info();
if (NULL == my_uri) {
return ORTE_ERROR;
}
fp = fopen(filename, "w"); fp = fopen(filename, "w");
if (NULL == fp) { if (NULL == fp) {
opal_output( 0, "Impossible to open the file %s in write mode\n", opal_output( 0, "Impossible to open the file %s in write mode\n",
@ -82,10 +89,6 @@ int orte_write_hnp_contact_file(char *filename)
return ORTE_ERR_FILE_OPEN_FAILURE; return ORTE_ERR_FILE_OPEN_FAILURE;
} }
my_uri = orte_rml.get_contact_info();
if (NULL == my_uri) {
return ORTE_ERROR;
}
fprintf(fp, "%s\n", my_uri); fprintf(fp, "%s\n", my_uri);
free(my_uri); free(my_uri);
@ -121,9 +124,11 @@ int orte_read_hnp_contact_file(char *filename, orte_hnp_contact_t *hnp, bool con
if (NULL == pidstr) { if (NULL == pidstr) {
ORTE_ERROR_LOG(ORTE_ERR_FILE_READ_FAILURE); ORTE_ERROR_LOG(ORTE_ERR_FILE_READ_FAILURE);
fclose(fp); fclose(fp);
free(hnp_uri);
return ORTE_ERR_FILE_READ_FAILURE; return ORTE_ERR_FILE_READ_FAILURE;
} }
hnp->pid = (pid_t)atol(pidstr); hnp->pid = (pid_t)atol(pidstr);
free(pidstr);
fclose(fp); fclose(fp);
if (connect) { if (connect) {
@ -133,12 +138,14 @@ int orte_read_hnp_contact_file(char *filename, orte_hnp_contact_t *hnp, bool con
/* extract the HNP's name and store it */ /* extract the HNP's name and store it */
if (ORTE_SUCCESS != (rc = orte_rml_base_parse_uris(hnp_uri, &hnp->name, NULL))) { if (ORTE_SUCCESS != (rc = orte_rml_base_parse_uris(hnp_uri, &hnp->name, NULL))) {
ORTE_ERROR_LOG(rc); ORTE_ERROR_LOG(rc);
free(hnp_uri);
return rc; return rc;
} }
/* set the route to be direct */ /* set the route to be direct */
if (ORTE_SUCCESS != (rc = orte_routed.update_route(&hnp->name, &hnp->name))) { if (ORTE_SUCCESS != (rc = orte_routed.update_route(&hnp->name, &hnp->name))) {
ORTE_ERROR_LOG(rc); ORTE_ERROR_LOG(rc);
free(hnp_uri);
return rc; return rc;
} }
} }
@ -218,14 +225,13 @@ int orte_list_local_hnps(opal_list_t *hnps, bool connect)
} else { } else {
OBJ_RELEASE(hnp); OBJ_RELEASE(hnp);
} }
free(contact_filename);
} }
cleanup: cleanup:
if( NULL != cur_dirp ) if( NULL != cur_dirp )
closedir(cur_dirp); closedir(cur_dirp);
free(headdir); free(headdir);
if( NULL != contact_filename)
free(contact_filename);
return (opal_list_is_empty(hnps) ? ORTE_ERR_NOT_FOUND : ORTE_SUCCESS); return (opal_list_is_empty(hnps) ? ORTE_ERR_NOT_FOUND : ORTE_SUCCESS);
} }

Просмотреть файл

@ -13,6 +13,8 @@
* reserved. * reserved.
* Copyright (c) 2011 Cisco Systems, Inc. All rights reserved. * Copyright (c) 2011 Cisco Systems, Inc. All rights reserved.
* Copyright (c) 2013-2014 Intel, Inc. All rights reserved. * Copyright (c) 2013-2014 Intel, Inc. All rights reserved.
* Copyright (c) 2015 Research Organization for Information Science
* and Technology (RIST). All rights reserved.
* $COPYRIGHT$ * $COPYRIGHT$
* *
* Additional copyrights may follow * Additional copyrights may follow
@ -234,6 +236,7 @@ static int hostfile_parse_line(int token, opal_list_t* updates,
/* this node was already found once - add a slot and mark slots as "given" */ /* this node was already found once - add a slot and mark slots as "given" */
node->slots++; node->slots++;
ORTE_FLAG_SET(node, ORTE_NODE_FLAG_SLOTS_GIVEN); ORTE_FLAG_SET(node, ORTE_NODE_FLAG_SLOTS_GIVEN);
free(node_name);
} }
/* do we need to record an alias for this node? */ /* do we need to record an alias for this node? */
if (NULL != node_alias) { if (NULL != node_alias) {
@ -298,13 +301,12 @@ static int hostfile_parse_line(int token, opal_list_t* updates,
node->slots = 1; node->slots = 1;
if (NULL != username) { if (NULL != username) {
orte_set_attribute(&node->attributes, ORTE_NODE_USERNAME, ORTE_ATTR_LOCAL, username, OPAL_STRING); orte_set_attribute(&node->attributes, ORTE_NODE_USERNAME, ORTE_ATTR_LOCAL, username, OPAL_STRING);
free(username);
username = NULL;
} }
opal_list_append(updates, &node->super); opal_list_append(updates, &node->super);
} else { } else {
/* add a slot */ /* add a slot */
node->slots++; node->slots++;
free(node_name);
} }
OPAL_OUTPUT_VERBOSE((1, orte_ras_base_framework.framework_output, OPAL_OUTPUT_VERBOSE((1, orte_ras_base_framework.framework_output,
"%s hostfile: node %s slots %d", "%s hostfile: node %s slots %d",
@ -323,6 +325,9 @@ static int hostfile_parse_line(int token, opal_list_t* updates,
hostfile_parse_error(token); hostfile_parse_error(token);
return ORTE_ERROR; return ORTE_ERROR;
} }
if (NULL != username) {
free(username);
}
while (!orte_util_hostfile_done) { while (!orte_util_hostfile_done) {
token = orte_util_hostfile_lex(); token = orte_util_hostfile_lex();
@ -339,7 +344,6 @@ static int hostfile_parse_line(int token, opal_list_t* updates,
if (NULL != username) { if (NULL != username) {
orte_set_attribute(&node->attributes, ORTE_NODE_USERNAME, ORTE_ATTR_LOCAL, username, OPAL_STRING); orte_set_attribute(&node->attributes, ORTE_NODE_USERNAME, ORTE_ATTR_LOCAL, username, OPAL_STRING);
free(username); free(username);
username = NULL;
} }
break; break;