1
1

btl/tcp: fix misc memory leaks

as reported by Coverity with CIDs 710615, 710616 and 710618
Этот коммит содержится в:
Gilles Gouaillardet 2015-02-27 19:16:22 +09:00
родитель 60404d1953
Коммит f33cd58ee9
2 изменённых файлов: 18 добавлений и 8 удалений

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

@ -532,9 +532,9 @@ static int mca_btl_tcp_component_create_instances(void)
const int if_count = opal_ifcount(); const int if_count = opal_ifcount();
int if_index; int if_index;
int kif_count = 0; int kif_count = 0;
int *kindexes = NULL; /* this array is way too large, but never too small */ int *kindexes; /* this array is way too large, but never too small */
char **include; char **include = NULL;
char **exclude; char **exclude = NULL;
char **argv; char **argv;
int ret = OPAL_SUCCESS; int ret = OPAL_SUCCESS;
@ -601,7 +601,6 @@ static int mca_btl_tcp_component_create_instances(void)
mca_btl_tcp_create(if_index, if_name); mca_btl_tcp_create(if_index, if_name);
argv++; argv++;
} }
opal_argv_free(include);
/* If we made any modules, then the "include" list was non-empty, /* If we made any modules, then the "include" list was non-empty,
and therefore we're done. */ and therefore we're done. */
@ -640,6 +639,12 @@ static int mca_btl_tcp_component_create_instances(void)
opal_argv_free(exclude); opal_argv_free(exclude);
cleanup: cleanup:
if (NULL != include) {
opal_argv_free(include);
}
if (NULL != exclude) {
opal_argv_free(exclude);
}
if (NULL != kindexes) { if (NULL != kindexes) {
free(kindexes); free(kindexes);
} }

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

@ -12,7 +12,7 @@
* All rights reserved. * All rights reserved.
* Copyright (c) 2008-2010 Oracle and/or its affiliates. All rights reserved * Copyright (c) 2008-2010 Oracle and/or its affiliates. All rights reserved
* Copyright (c) 2013-2014 Intel, Inc. All rights reserved * 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. * and Technology (RIST). All rights reserved.
* $COPYRIGHT$ * $COPYRIGHT$
* *
@ -328,7 +328,7 @@ static mca_btl_tcp_interface_t** mca_btl_tcp_retrieve_local_interfaces(void)
local_interfaces = (mca_btl_tcp_interface_t**)realloc( local_interfaces, local_interfaces = (mca_btl_tcp_interface_t**)realloc( local_interfaces,
max_local_interfaces * sizeof(mca_btl_tcp_interface_t*) ); max_local_interfaces * sizeof(mca_btl_tcp_interface_t*) );
if( NULL == local_interfaces ) if( NULL == local_interfaces )
return NULL; goto cleanup;
} }
local_interfaces[index] = (mca_btl_tcp_interface_t *) malloc(sizeof(mca_btl_tcp_interface_t)); local_interfaces[index] = (mca_btl_tcp_interface_t *) malloc(sizeof(mca_btl_tcp_interface_t));
assert(NULL != local_interfaces[index]); assert(NULL != local_interfaces[index]);
@ -369,8 +369,13 @@ static mca_btl_tcp_interface_t** mca_btl_tcp_retrieve_local_interfaces(void)
local_addr.ss_family); local_addr.ss_family);
} }
} }
opal_argv_free(include); cleanup:
opal_argv_free(exclude); if (NULL != include) {
opal_argv_free(include);
}
if (NULL != exclude) {
opal_argv_free(exclude);
}
return local_interfaces; return local_interfaces;
} }