@@ -202,7 +202,6 @@ dapl_extensions(IN DAT_HANDLE dat_handle,
status = DAT_ERROR(DAT_INVALID_HANDLE,
DAT_INVALID_HANDLE_EP);
else {
- cm->ah = NULL; /* consumer will free AH */
status = dapls_ud_cm_free(ep, cm);
}
break;
@@ -210,6 +209,7 @@ dapl_extensions(IN DAT_HANDLE dat_handle,
case DAT_IB_UD_AH_FREE_OP:
{
DAT_IB_ADDR_HANDLE *dat_ah;
+ uint16_t lid;
int ret;
dapl_dbg_log(DAPL_DBG_TYPE_RTN,
@@ -222,8 +222,18 @@ dapl_extensions(IN DAT_HANDLE dat_handle,
status = DAT_ERROR(DAT_INVALID_HANDLE,
DAT_INVALID_HANDLE_EP);
} else {
+ lid = ntohs(((union dcm_addr *)&dat_ah->ia_addr)->ib.lid);
+
+ if (lid > DCM_AH_SPACE) {
+ status = DAT_ERROR(DAT_INVALID_PARAMETER,
+ DAT_INVALID_ARG2);
+ break;
+ }
+
errno = 0;
- ret = ibv_destroy_ah(dat_ah->ah);
+ if (!((DAPL_EP *)ep)->qp_handle->ah[lid])
+ ret = ibv_destroy_ah(dat_ah->ah);
+
status = dapl_convert_errno(errno, "destroy_ah");
}
break;