Skip to content

Commit 41c2007

Browse files
authored
Merge pull request #6820 from wckzhang/cleanup
btl tcp: Fix error path memory leak
2 parents 06c6325 + 8c3b8a8 commit 41c2007

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

opal/mca/btl/tcp/btl_tcp_proc.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
* Copyright (c) 2015-2016 Los Alamos National Security, LLC. All rights
1818
* reserved.
1919
* Copyright (c) 2015-2018 Cisco Systems, Inc. All rights reserved
20-
* Copyright (c) 2018 Amazon.com, Inc. or its affiliates. All Rights reserved.
20+
* Copyright (c) 2018-2019 Amazon.com, Inc. or its affiliates. All Rights reserved.
2121
* $COPYRIGHT$
2222
*
2323
* Additional copyrights may follow
@@ -198,8 +198,6 @@ mca_btl_tcp_proc_t* mca_btl_tcp_proc_create(opal_proc_t* proc)
198198
}
199199
}
200200

201-
free(remote_addrs);
202-
203201
/* allocate space for endpoint array - one for each exported address */
204202
btl_proc->proc_endpoints = (mca_btl_base_endpoint_t**)
205203
malloc((1 + btl_proc->proc_addr_count) *
@@ -223,6 +221,10 @@ mca_btl_tcp_proc_t* mca_btl_tcp_proc_create(opal_proc_t* proc)
223221
}
224222
}
225223

224+
if (NULL != remote_addrs) {
225+
free(remote_addrs);
226+
}
227+
226228
OPAL_THREAD_UNLOCK(&mca_btl_tcp_component.tcp_lock);
227229

228230
return btl_proc;

0 commit comments

Comments
 (0)