@@ -421,13 +421,22 @@ ompi_mtl_ofi_send_generic(struct mca_mtl_base_module_t *mtl,
421421 sep_peer_fiaddr = fi_rx_addr (endpoint -> peer_fiaddr , ctxt_id , ompi_mtl_ofi .rx_ctx_bits );
422422
423423 ompi_ret = ompi_mtl_datatype_pack (convertor , & start , & length , & free_after );
424- if (OMPI_SUCCESS != ompi_ret ) return ompi_ret ;
424+ if (OPAL_UNLIKELY (OMPI_SUCCESS != ompi_ret )) {
425+ return ompi_ret ;
426+ }
425427
426428 ofi_req .buffer = (free_after ) ? start : NULL ;
427429 ofi_req .length = length ;
428430 ofi_req .status .MPI_ERROR = OMPI_SUCCESS ;
429431 ofi_req .completion_count = 0 ;
430432
433+ if (OPAL_UNLIKELY (length > endpoint -> mtl_ofi_module -> max_msg_size )) {
434+ opal_show_help ("help-mtl-ofi.txt" ,
435+ "message too big" , false,
436+ length , endpoint -> mtl_ofi_module -> max_msg_size );
437+ return OMPI_ERROR ;
438+ }
439+
431440 if (ofi_cq_data ) {
432441 match_bits = mtl_ofi_create_send_tag_CQD (comm -> c_contextid , tag );
433442 src_addr = sep_peer_fiaddr ;
@@ -553,13 +562,20 @@ ompi_mtl_ofi_isend_generic(struct mca_mtl_base_module_t *mtl,
553562 sep_peer_fiaddr = fi_rx_addr (endpoint -> peer_fiaddr , ctxt_id , ompi_mtl_ofi .rx_ctx_bits );
554563
555564 ompi_ret = ompi_mtl_datatype_pack (convertor , & start , & length , & free_after );
556- if (OMPI_SUCCESS != ompi_ret ) return ompi_ret ;
565+ if (OMPI_UNLIKELY ( OMPI_SUCCESS != ompi_ret ) ) return ompi_ret ;
557566
558567 ofi_req -> buffer = (free_after ) ? start : NULL ;
559568 ofi_req -> length = length ;
560569 ofi_req -> status .MPI_ERROR = OMPI_SUCCESS ;
561570 ofi_req -> completion_count = 1 ;
562571
572+ if (OPAL_UNLIKELY (length > endpoint -> mtl_ofi_module -> max_msg_size )) {
573+ opal_show_help ("help-mtl-ofi.txt" ,
574+ "message too big" , false,
575+ length , endpoint -> mtl_ofi_module -> max_msg_size );
576+ return OMPI_ERROR ;
577+ }
578+
563579 if (ofi_cq_data ) {
564580 match_bits = mtl_ofi_create_send_tag_CQD (comm -> c_contextid , tag );
565581 } else {
0 commit comments