Skip to content

Commit fd32ec9

Browse files
committed
Fixing valgrind memory leaks
Applying fixes from #8217 Signed-off-by: Geoffrey Paulsen <gpaulsen@us.ibm.com>
1 parent df456cd commit fd32ec9

File tree

8 files changed

+49
-4
lines changed

8 files changed

+49
-4
lines changed

ompi/mca/common/monitoring/common_monitoring.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,8 +228,17 @@ int mca_common_monitoring_init( void )
228228

229229
void mca_common_monitoring_finalize( void )
230230
{
231-
if( ! mca_common_monitoring_enabled || /* Don't release if not last */
232-
0 < opal_atomic_sub_fetch_32(&mca_common_monitoring_hold, 1) ) return;
231+
/* Even if not enabled, this string is allocated at l.310 */
232+
if( ! mca_common_monitoring_enabled ) {
233+
if( NULL != mca_common_monitoring_current_filename ) {
234+
free(mca_common_monitoring_current_filename);
235+
mca_common_monitoring_current_filename = NULL;
236+
}
237+
return;
238+
}
239+
240+
/* Don't release if not last */
241+
if(0 < opal_atomic_sub_fetch_32(&mca_common_monitoring_hold, 1) ) return;
233242

234243
OPAL_MONITORING_PRINT_INFO("common_component_finish");
235244
/* Dump monitoring informations */

ompi/mca/mtl/ofi/mtl_ofi.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ ompi_mtl_ofi_add_procs(struct mca_mtl_base_module_t *mtl,
104104
goto bail;
105105
}
106106
memcpy(&ep_names[i*namelen], ep_name, namelen);
107+
free(ep_name); // malloc'd inside OFI_COMPAT_MODEX_RECV in pmix3x.c:1097
107108
}
108109

109110
/**

ompi/mca/mtl/ofi/mtl_ofi_component.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -821,6 +821,12 @@ ompi_mtl_ofi_finalize(struct mca_mtl_base_module_t *mtl)
821821
goto finalize_err;
822822
}
823823

824+
/* This was strdup()ed at L.714 */
825+
if(NULL != ompi_mtl_ofi.provider_name) {
826+
free(ompi_mtl_ofi.provider_name);
827+
ompi_mtl_ofi.provider_name = NULL;
828+
}
829+
824830
return OMPI_SUCCESS;
825831

826832
finalize_err:

opal/mca/btl/openib/btl_openib_component.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,11 @@ static int btl_openib_component_close(void)
211211
OBJ_DESTRUCT(&mca_btl_openib_component.srq_manager.lock);
212212
OBJ_DESTRUCT(&mca_btl_openib_component.srq_manager.srq_addr_table);
213213

214+
/* destroy the tx/rx queues */
215+
OBJ_DESTRUCT(&mca_btl_openib_component.send_free_coalesced);
216+
OBJ_DESTRUCT(&mca_btl_openib_component.send_user_free);
217+
OBJ_DESTRUCT(&mca_btl_openib_component.recv_user_free);
218+
214219
opal_btl_openib_connect_base_finalize();
215220
opal_btl_openib_ini_finalize();
216221

@@ -912,6 +917,7 @@ static void device_construct(mca_btl_openib_device_t *device)
912917
device->ib_channel = NULL;
913918
#endif
914919
device->btls = 0;
920+
device->allowed_btls = 0;
915921
device->endpoints = NULL;
916922
device->device_btls = NULL;
917923
device->ib_cq[BTL_OPENIB_HP_CQ] = NULL;
@@ -1876,6 +1882,8 @@ static int init_one_device(opal_list_t *btl_list, struct ibv_device* ib_dev)
18761882
device->rcache =
18771883
mca_rcache_base_module_create (mca_btl_openib_component.ib_rcache_name,
18781884
device, &rcache_resources);
1885+
free(rcache_resources.cache_name);
1886+
18791887
if (NULL == device->rcache) {
18801888
/* Don't print an error message here -- we'll get one from
18811889
mpool_create anyway */
@@ -2277,6 +2285,7 @@ static int init_one_device(opal_list_t *btl_list, struct ibv_device* ib_dev)
22772285
} else if (device->btls > 0) {
22782286
/* no port is allowed to be used by btl/openib,
22792287
* so release the device right away */
2288+
OBJ_RELEASE(device->device_btls);
22802289
OBJ_RELEASE(device);
22812290
return OPAL_SUCCESS;
22822291
}
@@ -2292,6 +2301,7 @@ static int init_one_device(opal_list_t *btl_list, struct ibv_device* ib_dev)
22922301
if (NULL != allowed_ports) {
22932302
free(allowed_ports);
22942303
}
2304+
OBJ_RELEASE(device->device_btls);
22952305
OBJ_RELEASE(device);
22962306
return ret;
22972307
}
@@ -2704,6 +2714,8 @@ btl_openib_component_init(int *num_btl_modules,
27042714
}
27052715
}
27062716

2717+
2718+
// These are used nowhere else, ergo...
27072719
OBJ_CONSTRUCT(&mca_btl_openib_component.send_free_coalesced, opal_free_list_t);
27082720
OBJ_CONSTRUCT(&mca_btl_openib_component.send_user_free, opal_free_list_t);
27092721
OBJ_CONSTRUCT(&mca_btl_openib_component.recv_user_free, opal_free_list_t);
@@ -2733,6 +2745,7 @@ btl_openib_component_init(int *num_btl_modules,
27332745
goto no_btls;
27342746
}
27352747

2748+
free(init_data);
27362749
init_data = (mca_btl_openib_frag_init_data_t *) malloc(sizeof(mca_btl_openib_frag_init_data_t));
27372750
if (NULL == init_data) {
27382751
BTL_ERROR(("Failed malloc: %s:%d", __FILE__, __LINE__));
@@ -2754,6 +2767,7 @@ btl_openib_component_init(int *num_btl_modules,
27542767
goto no_btls;
27552768
}
27562769

2770+
free(init_data);
27572771
init_data = (mca_btl_openib_frag_init_data_t *) malloc(sizeof(mca_btl_openib_frag_init_data_t));
27582772
if (NULL == init_data) {
27592773
BTL_ERROR(("Failed malloc: %s:%d", __FILE__, __LINE__));
@@ -2773,6 +2787,8 @@ btl_openib_component_init(int *num_btl_modules,
27732787
goto no_btls;
27742788
}
27752789

2790+
free(init_data);
2791+
27762792
/* If fork support is requested, try to enable it */
27772793
if (OPAL_SUCCESS != (ret = opal_common_verbs_fork_test())) {
27782794
goto no_btls;
@@ -3058,6 +3074,8 @@ btl_openib_component_init(int *num_btl_modules,
30583074
if (NULL != btls) {
30593075
free(btls);
30603076
}
3077+
3078+
opal_ibv_free_device_list(ib_devs);
30613079
return NULL;
30623080
}
30633081

opal/mca/btl/openib/btl_openib_ini.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,13 +358,15 @@ static int parse_line(parsed_section_values_t *sv)
358358
if (0 == strcasecmp(key_buffer, "vendor_id")) {
359359
if (OPAL_SUCCESS != (ret = opal_btl_openib_ini_intify_list(value, &sv->vendor_ids,
360360
&sv->vendor_ids_len))) {
361+
free(value);
361362
return ret;
362363
}
363364
}
364365

365366
else if (0 == strcasecmp(key_buffer, "vendor_part_id")) {
366367
if (OPAL_SUCCESS != (ret = opal_btl_openib_ini_intify_list(value, &sv->vendor_part_ids,
367368
&sv->vendor_part_ids_len))) {
369+
free(value);
368370
return ret;
369371
}
370372
}
@@ -468,6 +470,10 @@ static void reset_section(bool had_previous_value, parsed_section_values_t *s)
468470
if (NULL != s->vendor_part_ids) {
469471
free(s->vendor_part_ids);
470472
}
473+
// This could be freed here, or had_previous_value forwarded to reset_values...
474+
if (NULL != s->values.receive_queues) {
475+
free(s->values.receive_queues);
476+
}
471477
}
472478

473479
s->name = NULL;

opal/mca/mpool/hugepage/mpool_hugepage_component.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,8 @@ static void mca_mpool_hugepage_find_hugepages (void) {
274274
opal_output_verbose (MCA_BASE_VERBOSE_INFO, opal_mpool_base_framework.framework_output,
275275
"found huge page with size = %lu, path = %s, mmap flags = 0x%x, with invalid "
276276
"permissions, skipping", hp->page_size, hp->path, hp->mmap_flags);
277-
}
277+
}
278+
OBJ_RELEASE(hp);
278279
}
279280

280281
opal_list_sort (&mca_mpool_hugepage_component.huge_pages, page_compare);

orte/mca/ess/base/ess_base_fns.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,10 @@ int orte_ess_base_proc_binding(void)
344344
}
345345
}
346346
}
347-
}
347+
} else {
348+
/* Prevent cpus from being unfreed if we fall through */
349+
hwloc_bitmap_free(cpus);
350+
}
348351
} else {
349352
OPAL_OUTPUT_VERBOSE((5, orte_ess_base_framework.framework_output,
350353
"%s Process bound at launch",

orte/util/show_help.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -721,6 +721,7 @@ int orte_show_help_norender(const char *filename, const char *topic,
721721
nanosleep(&tp, NULL);
722722
}
723723
OBJ_RELEASE(buf);
724+
free(kv->data.bo.bytes);
724725
kv->data.bo.bytes = NULL;
725726
OPAL_LIST_DESTRUCT(&info);
726727
rc = ORTE_SUCCESS;

0 commit comments

Comments
 (0)