Skip to content

Commit 91ab0e2

Browse files
Sergey OblomovTomislav Janjusic
authored andcommitted
SPML/UCX: fixed coverity issues
- fixed sizeof(char***) by variable datatype - fixed resorce leak in proc_add Signed-off-by: Sergey Oblomov <[email protected]> (cherry picked from commit 8543860)
1 parent 0daf3df commit 91ab0e2

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

oshmem/mca/spml/ucx/spml_ucx.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -326,10 +326,10 @@ int mca_spml_ucx_add_procs(ompi_proc_t** procs, size_t nprocs)
326326

327327
opal_progress_register(spml_ucx_default_progress);
328328

329-
mca_spml_ucx.remote_addrs_tbl = (char ***)calloc(mca_spml_ucx.ucp_workers, sizeof(char ***));
329+
mca_spml_ucx.remote_addrs_tbl = (char ***)calloc(mca_spml_ucx.ucp_workers,
330+
sizeof(mca_spml_ucx.remote_addrs_tbl[0]));
330331
for (w = 0; w < ucp_workers; w++) {
331-
mca_spml_ucx.remote_addrs_tbl[w] = (char **)calloc(nprocs, sizeof(char **));
332-
memset(mca_spml_ucx.remote_addrs_tbl[w], 0, nprocs * sizeof(char **));
332+
mca_spml_ucx.remote_addrs_tbl[w] = (char **)calloc(nprocs, sizeof(mca_spml_ucx.remote_addrs_tbl[w][0]));
333333
}
334334

335335
/* Store all remote addresses */
@@ -372,6 +372,8 @@ int mca_spml_ucx_add_procs(ompi_proc_t** procs, size_t nprocs)
372372
free(wk_raddrs);
373373
free(wk_rsizes);
374374
free(wk_roffs);
375+
free(wk_addr_len);
376+
free(wk_local_addr);
375377

376378
SPML_UCX_VERBOSE(50, "*** ADDED PROCS ***");
377379

@@ -407,6 +409,8 @@ int mca_spml_ucx_add_procs(ompi_proc_t** procs, size_t nprocs)
407409
free(wk_rsizes);
408410
free(wk_roffs);
409411
error:
412+
free(wk_addr_len);
413+
free(wk_local_addr);
410414
rc = OSHMEM_ERR_OUT_OF_RESOURCE;
411415
SPML_UCX_ERROR("add procs FAILED rc=%d", rc);
412416
return rc;

0 commit comments

Comments
 (0)