Skip to content

Commit 1d1cef7

Browse files
committed
opal: fix leaks
Two leaks are fixed by this commit: - opal_dss.lookup_data_type returns an allocated string. Free it. - opal_ifaddrtokindex was leaking a struct addrinfo. Ensure that is released before returning. cmr=v1.8.2:reviewer=rhc This commit was SVN r31777.
1 parent 59d09ad commit 1d1cef7

File tree

2 files changed

+20
-10
lines changed

2 files changed

+20
-10
lines changed

opal/mca/dstore/hash/dstore_hash.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1+
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
12
/*
23
* Copyright (c) 2010 Cisco Systems, Inc. All rights reserved.
34
* Copyright (c) 2004-2011 The University of Tennessee and The University
45
* of Tennessee Research Foundation. All rights
56
* reserved.
6-
* Copyright (c) 2011-2013 Los Alamos National Security, LLC. All rights
7+
* Copyright (c) 2011-2014 Los Alamos National Security, LLC. All rights
78
* reserved.
8-
* $COPYRIGHT$
9+
* $COPYRIGHT$
910
*
1011
* Additional copyrights may follow
1112
*
@@ -126,11 +127,15 @@ static int store(struct opal_dstore_base_module_t *imod,
126127
* a pre-existing value
127128
*/
128129
kv = opal_dstore_base_lookup_keyval(proc_data, val->key);
130+
#if OPAL_ENABLE_DEBUG
131+
char *_data_type = opal_dss.lookup_data_type(val->type);
129132
OPAL_OUTPUT_VERBOSE((5, opal_dstore_base_framework.framework_output,
130133
"dstore:hash:store: %s key %s[%s] for proc %" PRIu64 "",
131134
(NULL == kv ? "storing" : "updating"),
132-
val->key, opal_dss.lookup_data_type(val->type), id));
133-
135+
val->key, _data_type, id));
136+
free (_data_type);
137+
#endif
138+
134139
if (NULL != kv) {
135140
opal_list_remove_item(&proc_data->data, &kv->super);
136141
OBJ_RELEASE(kv);

opal/util/if.c

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
12
/*
23
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
34
* University Research and Technology
@@ -11,6 +12,8 @@
1112
* All rights reserved.
1213
* Copyright (c) 2008 Sun Microsystems, Inc. All rights reserved.
1314
* Copyright (c) 2010-2013 Cisco Systems, Inc. All rights reserved.
15+
* Copyright (c) 2014 Los Alamos National Security, LLC. All rights
16+
* reserved.
1417
* $COPYRIGHT$
1518
*
1619
* Additional copyrights may follow
@@ -264,6 +267,7 @@ int16_t opal_ifaddrtokindex(const char* if_addr)
264267
opal_if_t* intf;
265268
int error;
266269
struct addrinfo hints, *res = NULL, *r;
270+
int if_kernel_index;
267271
size_t len;
268272

269273
if (OPAL_SUCCESS != mca_base_framework_open(&opal_if_base_framework, 0)) {
@@ -283,16 +287,15 @@ int16_t opal_ifaddrtokindex(const char* if_addr)
283287
}
284288

285289
for (r = res; r != NULL; r = r->ai_next) {
286-
for (intf = (opal_if_t*)opal_list_get_first(&opal_if_list);
287-
intf != (opal_if_t*)opal_list_get_end(&opal_if_list);
288-
intf = (opal_if_t*)opal_list_get_next(intf)) {
289-
290+
OPAL_LIST_FOREACH(intf, &opal_if_list, opal_if_t) {
290291
if (AF_INET == r->ai_family && AF_INET == intf->af_family) {
291292
struct sockaddr_in ipv4;
292293
len = (r->ai_addrlen < sizeof(struct sockaddr_in)) ? r->ai_addrlen : sizeof(struct sockaddr_in);
293294
memcpy(&ipv4, r->ai_addr, len);
294295
if (opal_net_samenetwork((struct sockaddr*)&ipv4, (struct sockaddr*)&intf->if_addr, intf->if_mask)) {
295-
return intf->if_kernel_index;
296+
if_kernel_index = intf->if_kernel_index;
297+
freeaddrinfo (res);
298+
return if_kernel_index;
296299
}
297300
}
298301
#if OPAL_ENABLE_IPV6
@@ -302,7 +305,9 @@ int16_t opal_ifaddrtokindex(const char* if_addr)
302305
memcpy(&ipv6, r->ai_addr, len);
303306
if (opal_net_samenetwork((struct sockaddr*)((struct sockaddr_in6*)&intf->if_addr),
304307
(struct sockaddr*)&ipv6, intf->if_mask)) {
305-
return intf->if_kernel_index;
308+
if_kernel_index = intf->if_kernel_index;
309+
freeaddrinfo (res);
310+
return if_kernel_index;
306311
}
307312
}
308313
#endif

0 commit comments

Comments
 (0)