Skip to content

Commit 3d1112e

Browse files
author
Ralph Castain
authored
Merge pull request #3760 from rhc54/topic/cov
Silence coverity warnings, correctly transfer the endpoint blob bytes
2 parents d55b666 + 6e2778a commit 3d1112e

File tree

2 files changed

+32
-32
lines changed

2 files changed

+32
-32
lines changed

orte/mca/rml/ofi/rml_ofi_component.c

Lines changed: 19 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -134,12 +134,6 @@ void free_ofi_prov_resources( int ofi_prov_id)
134134
opal_output_verbose(10,orte_rml_base_framework.framework_output,
135135
" %s - close ep",ORTE_NAME_PRINT(ORTE_PROC_MY_NAME));
136136
CLOSE_FID(orte_rml_ofi.ofi_prov[ofi_prov_id].ep);
137-
if (ret)
138-
{
139-
opal_output_verbose(10,orte_rml_base_framework.framework_output,
140-
" %s - fi_close(ep) failed with error- %d",
141-
ORTE_NAME_PRINT(ORTE_PROC_MY_NAME),ret);
142-
}
143137
}
144138
if (orte_rml_ofi.ofi_prov[ofi_prov_id].mr_multi_recv) {
145139
opal_output_verbose(10,orte_rml_base_framework.framework_output,
@@ -745,28 +739,33 @@ static int rml_ofi_component_init(void)
745739
/* pack the provider's name */
746740
if (OPAL_SUCCESS != (ret = opal_dss.pack(&entry, &(orte_rml_ofi.ofi_prov[cur_ofi_prov].fabric_info->fabric_attr->prov_name), 1, OPAL_STRING))) {
747741
OBJ_DESTRUCT(&entry);
742+
free_ofi_prov_resources(cur_ofi_prov);
748743
continue;
749744
}
750745
/* pack the provider's local index */
751746
if (OPAL_SUCCESS != (ret = opal_dss.pack(&entry, &cur_ofi_prov, 1, OPAL_UINT8))) {
752747
OBJ_DESTRUCT(&entry);
748+
free_ofi_prov_resources(cur_ofi_prov);
753749
continue;
754750
}
755751
/* pack the size of the provider's connection blob */
756752
if (OPAL_SUCCESS != (ret = opal_dss.pack(&entry, &orte_rml_ofi.ofi_prov[cur_ofi_prov].epnamelen, 1, OPAL_SIZE))) {
757753
OBJ_DESTRUCT(&entry);
754+
free_ofi_prov_resources(cur_ofi_prov);
758755
continue;
759756
}
760757
/* pack the blob itself */
761-
if (OPAL_SUCCESS != (ret = opal_dss.pack(&entry, &orte_rml_ofi.ofi_prov[cur_ofi_prov].ep_name,
758+
if (OPAL_SUCCESS != (ret = opal_dss.pack(&entry, orte_rml_ofi.ofi_prov[cur_ofi_prov].ep_name,
762759
orte_rml_ofi.ofi_prov[cur_ofi_prov].epnamelen, OPAL_BYTE))) {
763760
OBJ_DESTRUCT(&entry);
761+
free_ofi_prov_resources(cur_ofi_prov);
764762
continue;
765763
}
766764
/* add this entry to the overall modex object */
767765
eptr = &entry;
768766
if (OPAL_SUCCESS != (ret = opal_dss.pack(&modex, &eptr, 1, OPAL_BUFFER))) {
769767
OBJ_DESTRUCT(&entry);
768+
free_ofi_prov_resources(cur_ofi_prov);
770769
continue;
771770
}
772771
OBJ_DESTRUCT(&entry);
@@ -789,15 +788,6 @@ static int rml_ofi_component_init(void)
789788
ntohs(ep_sockaddr->sin_port), inet_ntoa(ep_sockaddr->sin_addr));
790789
break;
791790
}
792-
/* end of printing opal_modex_string and port, IP */
793-
if (ORTE_SUCCESS != ret) {
794-
opal_output_verbose(1, orte_rml_base_framework.framework_output,
795-
"%s:%d: OPAL_MODEX_SEND failed: %s\n",
796-
__FILE__, __LINE__, fi_strerror(-ret));
797-
free_ofi_prov_resources(cur_ofi_prov);
798-
/*abort this current transport, but check if next transport can be opened*/
799-
continue;
800-
}
801791

802792
/**
803793
* Set the ANY_SRC address.
@@ -944,7 +934,8 @@ int get_ofi_prov_id( opal_list_t *attributes)
944934
* (or) ORTE_RML_OFI_PROV_NAME key with values "socket" or "OPA"
945935
* if both above attributes are missing return failure
946936
*/
947-
if (orte_get_attribute(attributes, ORTE_RML_TRANSPORT_ATTRIB, (void**)&transport, OPAL_STRING) ) {
937+
if (orte_get_attribute(attributes, ORTE_RML_TRANSPORT_ATTRIB, (void**)&transport, OPAL_STRING) &&
938+
NULL != transport) {
948939
if( 0 == strcmp( transport, "ethernet") ) {
949940
provider = ethernet;
950941
} else if ( 0 == strcmp( transport, "fabric") ) {
@@ -953,21 +944,19 @@ int get_ofi_prov_id( opal_list_t *attributes)
953944
}
954945
/* if from the transport we don't know which provider we want, then check for the ORTE_RML_OFI_PROV_NAME_ATTRIB */
955946
if ( NULL == provider) {
956-
orte_get_attribute(attributes, ORTE_RML_PROVIDER_ATTRIB, (void**)&provider, OPAL_STRING);
957-
}
958-
if (NULL != provider)
959-
{
960-
// loop the orte_rml_ofi.ofi_provs[] and find the provider name that matches
961-
for ( prov_num = 0; prov_num < orte_rml_ofi.ofi_prov_open_num && ofi_prov_id == RML_OFI_PROV_ID_INVALID ; prov_num++ ) {
962-
cur_fi = orte_rml_ofi.ofi_prov[prov_num].fabric_info;
963-
opal_output_verbose(20,orte_rml_base_framework.framework_output,
964-
"%s - get_ofi_prov_id() -> comparing %s = %s ",
965-
ORTE_NAME_PRINT(ORTE_PROC_MY_NAME),provider,cur_fi->fabric_attr->prov_name);
966-
if ( strcmp(provider,cur_fi->fabric_attr->prov_name) == 0) {
967-
ofi_prov_id = prov_num;
947+
if (orte_get_attribute(attributes, ORTE_RML_PROVIDER_ATTRIB, (void**)&provider, OPAL_STRING) &&
948+
NULL != provider) {
949+
// loop the orte_rml_ofi.ofi_provs[] and find the provider name that matches
950+
for ( prov_num = 0; prov_num < orte_rml_ofi.ofi_prov_open_num && ofi_prov_id == RML_OFI_PROV_ID_INVALID ; prov_num++ ) {
951+
cur_fi = orte_rml_ofi.ofi_prov[prov_num].fabric_info;
952+
opal_output_verbose(20,orte_rml_base_framework.framework_output,
953+
"%s - get_ofi_prov_id() -> comparing %s = %s ",
954+
ORTE_NAME_PRINT(ORTE_PROC_MY_NAME),provider,cur_fi->fabric_attr->prov_name);
955+
if ( strcmp(provider,cur_fi->fabric_attr->prov_name) == 0) {
956+
ofi_prov_id = prov_num;
957+
}
968958
}
969959
}
970-
971960
}
972961

973962
opal_output_verbose(20,orte_rml_base_framework.framework_output,

orte/mca/rml/ofi/rml_ofi_send.c

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,9 @@ int orte_rml_ofi_recv_handler(struct fi_cq_data_entry *wc, uint8_t ofi_prov_id)
243243
"%s Adding data for packet %d, pktlength = %lu, cumulative datalen so far = %d",
244244
ORTE_NAME_PRINT(ORTE_PROC_MY_NAME), ofi_recv_pkt->cur_pkt_num, ofi_recv_pkt->pkt_size, datalen );
245245
if (0 == datalen) {
246+
if (NULL != totdata) {
247+
free(totdata);
248+
}
246249
totdata = (char *)malloc(ofi_recv_pkt->pkt_size);
247250
if( totdata == NULL) {
248251
opal_output_verbose(1, orte_rml_base_framework.framework_output,
@@ -462,15 +465,23 @@ static void send_msg(int fd, short args, void *cbdata)
462465
bytes = (uint8_t*)malloc(entrysize);
463466
/* unpack the connection blob */
464467
cnt = entrysize;
465-
if (OPAL_SUCCESS != (ret = opal_dss.unpack(entry, &bytes, &cnt, OPAL_BYTE))) {
468+
if (OPAL_SUCCESS != (ret = opal_dss.unpack(entry, bytes, &cnt, OPAL_BYTE))) {
466469
ORTE_ERROR_LOG(ret);
467470
OBJ_RELEASE(entry);
468471
break;
469472
}
470473
/* done with the buffer */
471474
OBJ_RELEASE(entry);
472475
/* decide if this is the provider we want to use - if so, then we are done.
473-
* If not, then we can simply free they bytes and continue looking */
476+
* If not, then we can simply free the bytes and continue looking. For now,
477+
* take the first one */
478+
pr = OBJ_NEW(orte_rml_ofi_peer_t);
479+
pr->ofi_ep = bytes;
480+
pr->ofi_ep_len = entrysize;
481+
opal_hash_table_set_value_uint64(&orte_rml_ofi.peers, ui64, (void*)pr);
482+
dest_ep_name = pr->ofi_ep;
483+
dest_ep_namelen = pr->ofi_ep_len;
484+
break;
474485
}
475486
OBJ_DESTRUCT(&modex); // releases the data returned by the modex_recv
476487
} else {

0 commit comments

Comments
 (0)