From 2ab9a411f8a8cd87add722e91e7db11ad0b35723 Mon Sep 17 00:00:00 2001 From: Gilles Gouaillardet Date: Mon, 9 Mar 2015 16:25:07 +0900 Subject: [PATCH] plm/base: fix misc memory leaks as reported by Coverity with CIDs 1196733 and 1196745 --- orte/mca/plm/base/plm_base_launch_support.c | 6 +++++- orte/mca/plm/base/plm_base_proxy.c | 8 ++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/orte/mca/plm/base/plm_base_launch_support.c b/orte/mca/plm/base/plm_base_launch_support.c index 4e255f9371..5dc8d5cb81 100644 --- a/orte/mca/plm/base/plm_base_launch_support.c +++ b/orte/mca/plm/base/plm_base_launch_support.c @@ -14,7 +14,7 @@ * et Automatique. All rights reserved. * Copyright (c) 2011-2012 Los Alamos National Security, LLC. * Copyright (c) 2013-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. * $COPYRIGHT$ * @@ -996,6 +996,10 @@ void orte_plm_base_daemon_callback(int status, orte_process_name_t* sender, } } } + if (NULL != nodename) { + free(nodename); + nodename = NULL; + } idx = 1; } if (ORTE_ERR_UNPACK_READ_PAST_END_OF_BUFFER != rc) { diff --git a/orte/mca/plm/base/plm_base_proxy.c b/orte/mca/plm/base/plm_base_proxy.c index ef986d1bce..476cf0f5fb 100644 --- a/orte/mca/plm/base/plm_base_proxy.c +++ b/orte/mca/plm/base/plm_base_proxy.c @@ -13,6 +13,8 @@ * Copyright (c) 2011-2012 Los Alamos National Security, LLC. * 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$ * * Additional copyrights may follow @@ -311,6 +313,7 @@ int orte_plm_base_fork_hnp(void) jobid = ORTE_DAEMON_JOBID(ORTE_PROC_MY_NAME->jobid); if (ORTE_SUCCESS != (rc = orte_util_convert_jobid_to_string(¶m, jobid))) { ORTE_ERROR_LOG(rc); + free(cmd); return rc; } opal_argv_append(&argc, &argv, param); @@ -364,6 +367,7 @@ int orte_plm_base_fork_hnp(void) exit(1); } else { + free(cmd); /* I am the parent - wait to hear something back and * report results */ @@ -430,11 +434,12 @@ int orte_plm_base_fork_hnp(void) if (ORTE_SUCCESS != (rc = orte_rml_base_parse_uris(orte_process_info.my_daemon_uri, ORTE_PROC_MY_DAEMON, NULL))) { ORTE_ERROR_LOG(rc); + free(orted_uri); return rc; } /* likewise, since this is also the HNP, set that uri too */ - orte_process_info.my_hnp_uri = strdup(orted_uri); + orte_process_info.my_hnp_uri = orted_uri; orte_rml.set_contact_info(orte_process_info.my_hnp_uri); if (ORTE_SUCCESS != (rc = orte_rml_base_parse_uris(orte_process_info.my_hnp_uri, ORTE_PROC_MY_HNP, NULL))) { @@ -457,7 +462,6 @@ int orte_plm_base_fork_hnp(void) return rc; } /* all done - report success */ - free(orted_uri); return ORTE_SUCCESS; } }