Skip to content

Commit 34093ce

Browse files
committed
btl/openib: fix udcm coverity errors
Fix CID 1312120: Uninitialized scalar variable The response type will always be set unless a message of another type is passed to this function. To make sure that error is caught I am adding an assert. Fix CID 1312116: Dereference after null check This is a potential bug. If there is no endpoint data for an incoming connection a rejection should be sent. In this case we would just SEGV. Fix CID 1312115: Dereference after null check Clear error in the error message. Use the queue pair number that was passed in. Signed-off-by: Nathan Hjelm <[email protected]> (cherry picked from open-mpi/ompi@60f3dbd)
1 parent 2ae0f3b commit 34093ce

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

opal/mca/btl/openib/connect/btl_openib_connect_udcm.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2631,8 +2631,8 @@ static int udcm_xrc_recv_qp_connect (mca_btl_openib_endpoint_t *lcl_ep)
26312631
lcl_ep->xrc_recv_qp = ibv_open_qp(openib_btl->device->ib_dev_context, &attr);
26322632
if (NULL == lcl_ep->xrc_recv_qp) { /* failed to regester the qp, so it is already die and we should create new one */
26332633
/* Return NOT READY !!!*/
2634-
BTL_ERROR(("Failed to register qp_num: %d , get error: %s (%d)\n. Replying with RNR",
2635-
lcl_ep->xrc_recv_qp->qp_num, strerror(errno), errno));
2634+
BTL_ERROR(("Failed to register qp_num: %d, get error: %s (%d)\n. Replying with RNR",
2635+
qp_num, strerror(errno), errno));
26362636
return OPAL_ERROR;
26372637
} else {
26382638
BTL_VERBOSE(("Connected to XRC Recv qp [%d]", lcl_ep->xrc_recv_qp->qp_num));
@@ -2908,6 +2908,9 @@ static int udcm_xrc_handle_xconnect (mca_btl_openib_endpoint_t *lcl_ep, udcm_msg
29082908
int response_type;
29092909
int rc = OPAL_ERROR;
29102910

2911+
/* sanity check on message type */
2912+
assert (UDCM_MESSAGE_XCONNECT == msg_hdr->type || UDCM_MESSAGE_XCONNECT2 == msg_hdr->type);
2913+
29112914
do {
29122915
if (NULL == udep) {
29132916
break;
@@ -2964,7 +2967,9 @@ static int udcm_xrc_handle_xconnect (mca_btl_openib_endpoint_t *lcl_ep, udcm_msg
29642967
return OPAL_SUCCESS;
29652968
} while (0);
29662969

2967-
opal_mutex_unlock (&udep->udep_lock);
2970+
if (udep) {
2971+
opal_mutex_unlock (&udep->udep_lock);
2972+
}
29682973

29692974
/* Reject the request */
29702975
BTL_VERBOSE(("rejecting request for reason %d", rej_reason));

0 commit comments

Comments
 (0)