1
1

orted/dfs: fix misc memory leaks

as reported by Coverity with CIDs 739887, 747706, 1196707-1196709 and 1269849
Этот коммит содержится в:
Gilles Gouaillardet 2015-05-20 13:09:46 +09:00
родитель 62a278d29c
Коммит dd28b1f680
2 изменённых файлов: 20 добавлений и 7 удалений

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

@ -3,6 +3,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) 2015 Intel, Inc. All rights reserved * Copyright (c) 2015 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
@ -1649,6 +1651,9 @@ static void recv_dfs_cmd(int status, orte_process_name_t* sender,
return; return;
} }
} }
if (NULL != read_buf) {
free(read_buf);
}
/* send it */ /* send it */
opal_output_verbose(1, orte_dfs_base_framework.framework_output, opal_output_verbose(1, orte_dfs_base_framework.framework_output,
"%s sending %ld bytes back to %s", "%s sending %ld bytes back to %s",
@ -1662,9 +1667,6 @@ static void recv_dfs_cmd(int status, orte_process_name_t* sender,
OBJ_RELEASE(answer); OBJ_RELEASE(answer);
return; return;
} }
if (NULL != read_buf) {
free(read_buf);
}
break; break;
case ORTE_DFS_POST_CMD: case ORTE_DFS_POST_CMD:
@ -2288,6 +2290,7 @@ static void remote_read(int fd, short args, void *cbdata)
return; return;
} }
} }
free(read_buf);
/* send it */ /* send it */
opal_output_verbose(1, orte_dfs_base_framework.framework_output, opal_output_verbose(1, orte_dfs_base_framework.framework_output,
"%s sending %ld bytes back to %s", "%s sending %ld bytes back to %s",
@ -2301,7 +2304,6 @@ static void remote_read(int fd, short args, void *cbdata)
OBJ_RELEASE(answer); OBJ_RELEASE(answer);
return; return;
} }
free(read_buf);
OBJ_RELEASE(req); OBJ_RELEASE(req);
} }

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

@ -2,7 +2,7 @@
* Copyright (c) 2012-2013 Los Alamos National Security, LLC. * Copyright (c) 2012-2013 Los Alamos National Security, LLC.
* All rights reserved. * All rights reserved.
* Copyright (c) 2014 Intel, Inc. All rights reserved * Copyright (c) 2014 Intel, Inc. All rights reserved
* Copyright (c) 2014 Research Organization for Information Science * Copyright (c) 2014-2015 Research Organization for Information Science
* and Technology (RIST). All rights reserved. * and Technology (RIST). All rights reserved.
* $COPYRIGHT$ * $COPYRIGHT$
* *
@ -446,7 +446,7 @@ static void process_opens(int fd, short args, void *cbdata)
orte_dfs_request_t *dfs = (orte_dfs_request_t*)cbdata; orte_dfs_request_t *dfs = (orte_dfs_request_t*)cbdata;
int rc; int rc;
opal_buffer_t *buffer; opal_buffer_t *buffer;
char *scheme, *host, *filename, *hostname; char *scheme, *host, *filename;
orte_process_name_t daemon; orte_process_name_t daemon;
bool found; bool found;
orte_vpid_t v; orte_vpid_t v;
@ -465,8 +465,10 @@ static void process_opens(int fd, short args, void *cbdata)
/* not yet supported */ /* not yet supported */
orte_show_help("orte_dfs_help.txt", "unsupported-filesystem", orte_show_help("orte_dfs_help.txt", "unsupported-filesystem",
true, dfs->uri); true, dfs->uri);
free(scheme);
goto complete; goto complete;
} }
free(scheme);
/* dissect the uri to extract host and filename/path */ /* dissect the uri to extract host and filename/path */
if (NULL == (filename = opal_filename_from_uri(dfs->uri, &host))) { if (NULL == (filename = opal_filename_from_uri(dfs->uri, &host))) {
@ -481,6 +483,7 @@ static void process_opens(int fd, short args, void *cbdata)
daemon.jobid = ORTE_PROC_MY_DAEMON->jobid; daemon.jobid = ORTE_PROC_MY_DAEMON->jobid;
found = false; found = false;
for (v=0; v < orte_process_info.num_daemons; v++) { for (v=0; v < orte_process_info.num_daemons; v++) {
char *hostname;
daemon.vpid = v; daemon.vpid = v;
/* fetch the hostname where this daemon is located */ /* fetch the hostname where this daemon is located */
OBJ_CONSTRUCT(&myvals, opal_list_t); OBJ_CONSTRUCT(&myvals, opal_list_t);
@ -492,7 +495,7 @@ static void process_opens(int fd, short args, void *cbdata)
goto complete; goto complete;
} }
kv = (opal_value_t*)opal_list_get_first(&myvals); kv = (opal_value_t*)opal_list_get_first(&myvals);
hostname = strdup(kv->data.string); hostname = kv->data.string;
OPAL_LIST_DESTRUCT(&myvals); OPAL_LIST_DESTRUCT(&myvals);
opal_output(0, "%s GOT HOST %s HOSTNAME %s", ORTE_NAME_PRINT(ORTE_PROC_MY_NAME), host, hostname); opal_output(0, "%s GOT HOST %s HOSTNAME %s", ORTE_NAME_PRINT(ORTE_PROC_MY_NAME), host, hostname);
if (0 == strcmp(host, hostname)) { if (0 == strcmp(host, hostname)) {
@ -551,12 +554,20 @@ static void process_opens(int fd, short args, void *cbdata)
goto complete; goto complete;
} }
/* don't release it */ /* don't release it */
free(host);
free(filename);
return; return;
complete: complete:
/* we get here if an error occurred - execute any /* we get here if an error occurred - execute any
* pending callback so the proc doesn't hang * pending callback so the proc doesn't hang
*/ */
if (NULL != host) {
free(host);
}
if (NULL != filename) {
free(filename);
}
if (NULL != dfs->open_cbfunc) { if (NULL != dfs->open_cbfunc) {
dfs->open_cbfunc(-1, dfs->cbdata); dfs->open_cbfunc(-1, dfs->cbdata);
} }