@@ -251,6 +251,10 @@ int mca_topo_treematch_dist_graph_create(mca_topo_base_module_t* topo_module,
251251 effective_depth = object -> depth ;
252252 num_objs_in_node = hwloc_get_nbobjs_by_depth (opal_hwloc_topology , effective_depth );
253253 }
254+ if ( 0 == num_objs_in_node ) { /* deal with bozo cases: COVERITY 1418505 */
255+ free (colors );
256+ goto fallback ; /* return with success */
257+ }
254258 /* Check for oversubscribing */
255259 oversubscribing_objs = check_oversubscribing (rank , num_nodes ,
256260 num_objs_in_node , num_procs_in_node ,
@@ -355,20 +359,20 @@ int mca_topo_treematch_dist_graph_create(mca_topo_base_module_t* topo_module,
355359 for (i = 1 ; i < num_procs_in_node ; i ++ ) {
356360 if (OMPI_SUCCESS != ( err = MCA_PML_CALL (irecv (& localrank_to_objnum [i ], 1 , MPI_INT ,
357361 lindex_to_grank [i ], -111 , comm_old , & reqs [i - 1 ])))) {
358- free (reqs );
362+ free (reqs ); reqs = NULL ;
359363 goto release_and_return ;
360364 }
361365 }
362366 if (OMPI_SUCCESS != ( err = ompi_request_wait_all (num_procs_in_node - 1 ,
363367 reqs , MPI_STATUSES_IGNORE ))) {
364- free (reqs );
368+ free (reqs ); reqs = NULL ;
365369 goto release_and_return ;
366370 }
367371 } else {
368372 /* sending my core number to my local master on the node */
369373 if (OMPI_SUCCESS != (err = MCA_PML_CALL (send (& obj_rank , 1 , MPI_INT , lindex_to_grank [0 ],
370374 -111 , MCA_PML_BASE_SEND_STANDARD , comm_old )))) {
371- free (reqs );
375+ free (reqs ); reqs = NULL ;
372376 goto release_and_return ;
373377 }
374378 }
@@ -703,14 +707,10 @@ int mca_topo_treematch_dist_graph_create(mca_topo_base_module_t* topo_module,
703707 (* newcomm )-> c_topo -> reorder = reorder ;
704708
705709 } else { /* partially distributed reordering */
710+ int * grank_to_lrank = NULL , * lrank_to_grank = NULL , * marked = NULL ;
711+ int node_position = 0 , offset = 0 , done = 0 , pos = 0 ;
706712 ompi_communicator_t * localcomm = NULL ;
707- int * grank_to_lrank , * lrank_to_grank ;
708- int * marked = (int * )malloc ((num_nodes - 1 )* sizeof (int ));
709- int node_position = 0 ;
710- int offset = 0 ;
711- int done = 0 ;
712- int pos = 0 ;
713-
713+
714714 if (OMPI_SUCCESS != (err = ompi_comm_split (comm_old , colors [rank ], rank ,
715715 & localcomm , false))) {
716716 goto release_and_return ;
@@ -874,10 +874,11 @@ int mca_topo_treematch_dist_graph_create(mca_topo_base_module_t* topo_module,
874874
875875 /* compute the offset of newrank before the split */
876876 /* use the colors array, not the vpids */
877+ marked = (int * )malloc ((num_nodes - 1 )* sizeof (int ));
877878 for (int idx = 0 ; idx < num_nodes - 1 ; idx ++ )
878879 marked [idx ] = -1 ;
879-
880- while ( (node_position != rank ) && (colors [node_position ] != colors [rank ])){
880+
881+ while ( (node_position != rank ) && (colors [node_position ] != colors [rank ])){
881882 for (int idx = 0 ; idx < num_nodes - 1 ; idx ++ )
882883 if ( marked [idx ] == colors [node_position ] )
883884 done = 1 ;
@@ -888,17 +889,18 @@ int mca_topo_treematch_dist_graph_create(mca_topo_base_module_t* topo_module,
888889 marked [pos ++ ] = colors [node_position ];
889890 }
890891 node_position ++ ;
891- }
892+ }
892893 newrank += offset ;
893894
894- if (rank == lindex_to_grank [0 ])
895+ if (rank == lindex_to_grank [0 ])
895896 free (k );
896897
897898 /* this needs to be optimized but will do for now */
898899 if (OMPI_SUCCESS != (err = ompi_comm_split (comm_old , 0 , newrank , newcomm , false))) {
899900 ompi_comm_free (& localcomm );
900901 free (lrank_to_grank );
901902 free (grank_to_lrank );
903+ free (marked ); marked = NULL ;
902904 goto release_and_return ;
903905 }
904906 /* end of TODO */
0 commit comments