From 134c866aa97d28a054361245338b21bdcace1e03 Mon Sep 17 00:00:00 2001 From: Gilles Gouaillardet Date: Tue, 3 Mar 2015 13:22:01 +0900 Subject: [PATCH] btl/openib: fix misc memory leaks as reported by Coverity with CIDs 1269848, 1269852 and 1269862 --- opal/mca/btl/openib/btl_openib_component.c | 9 +++++++-- opal/mca/btl/openib/connect/btl_openib_connect_base.c | 1 + 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/opal/mca/btl/openib/btl_openib_component.c b/opal/mca/btl/openib/btl_openib_component.c index 284ee53229..80a51b64f6 100644 --- a/opal/mca/btl/openib/btl_openib_component.c +++ b/opal/mca/btl/openib/btl_openib_component.c @@ -1633,7 +1633,6 @@ static int init_one_device(opal_list_t *btl_list, struct ibv_device* ib_dev) port_cnt = get_port_list(device, allowed_ports); if (0 == port_cnt) { - free(allowed_ports); ret = OPAL_SUCCESS; ++num_devices_intentionally_ignored; goto error; @@ -2207,6 +2206,9 @@ error: if (device->ib_dev_context) { ibv_close_device(device->ib_dev_context); } + if (NULL != allowed_ports) { + free(allowed_ports); + } OBJ_RELEASE(device); return ret; } @@ -2465,7 +2467,7 @@ btl_openib_component_init(int *num_btl_modules, bool enable_mpi_threads) { struct ibv_device **ib_devs; - mca_btl_base_module_t** btls; + mca_btl_base_module_t** btls = NULL; int i, ret, num_devs, length; opal_list_t btl_list; mca_btl_openib_module_t * openib_btl; @@ -2905,6 +2907,9 @@ btl_openib_component_init(int *num_btl_modules, __malloc_hook = mca_btl_openib_component.previous_malloc_hook; } #endif + if (NULL != btls) { + free(btls); + } return NULL; } diff --git a/opal/mca/btl/openib/connect/btl_openib_connect_base.c b/opal/mca/btl/openib/connect/btl_openib_connect_base.c index cc90c497bd..6865651497 100644 --- a/opal/mca/btl/openib/connect/btl_openib_connect_base.c +++ b/opal/mca/btl/openib/connect/btl_openib_connect_base.c @@ -264,6 +264,7 @@ int opal_btl_openib_connect_base_select_for_local_port(mca_btl_openib_module_t * } msg = (char *) malloc(len); if (NULL == msg) { + free(cpcs); return OPAL_ERR_OUT_OF_RESOURCE; } msg[0] = '\0';