@@ -308,13 +308,22 @@ ompi_mtl_ofi_send(struct mca_mtl_base_module_t *mtl,
308308 endpoint = ompi_mtl_ofi_get_endpoint (mtl , ompi_proc );
309309
310310 ompi_ret = ompi_mtl_datatype_pack (convertor , & start , & length , & free_after );
311- if (OMPI_SUCCESS != ompi_ret ) return ompi_ret ;
311+ if (OPAL_UNLIKELY (OMPI_SUCCESS != ompi_ret )) {
312+ return ompi_ret ;
313+ }
312314
313315 ofi_req .buffer = (free_after ) ? start : NULL ;
314316 ofi_req .length = length ;
315317 ofi_req .status .MPI_ERROR = OMPI_SUCCESS ;
316318 ofi_req .completion_count = 0 ;
317319
320+ if (OPAL_UNLIKELY (length > endpoint -> mtl_ofi_module -> max_msg_size )) {
321+ opal_show_help ("help-mtl-ofi.txt" ,
322+ "message too big" , false,
323+ length , endpoint -> mtl_ofi_module -> max_msg_size );
324+ return OMPI_ERROR ;
325+ }
326+
318327 if (ompi_mtl_ofi .fi_cq_data ) {
319328 match_bits = mtl_ofi_create_send_tag_CQD (comm -> c_contextid , tag );
320329 src_addr = endpoint -> peer_fiaddr ;
@@ -438,13 +447,20 @@ ompi_mtl_ofi_isend(struct mca_mtl_base_module_t *mtl,
438447 endpoint = ompi_mtl_ofi_get_endpoint (mtl , ompi_proc );
439448
440449 ompi_ret = ompi_mtl_datatype_pack (convertor , & start , & length , & free_after );
441- if (OMPI_SUCCESS != ompi_ret ) return ompi_ret ;
450+ if (OMPI_UNLIKELY ( OMPI_SUCCESS != ompi_ret ) ) return ompi_ret ;
442451
443452 ofi_req -> buffer = (free_after ) ? start : NULL ;
444453 ofi_req -> length = length ;
445454 ofi_req -> status .MPI_ERROR = OMPI_SUCCESS ;
446455 ofi_req -> completion_count = 1 ;
447456
457+ if (OPAL_UNLIKELY (length > endpoint -> mtl_ofi_module -> max_msg_size )) {
458+ opal_show_help ("help-mtl-ofi.txt" ,
459+ "message too big" , false,
460+ length , endpoint -> mtl_ofi_module -> max_msg_size );
461+ return OMPI_ERROR ;
462+ }
463+
448464 if (ompi_mtl_ofi .fi_cq_data ) {
449465 match_bits = mtl_ofi_create_send_tag_CQD (comm -> c_contextid , tag );
450466 src_addr = endpoint -> peer_fiaddr ;
0 commit comments