11/**
2- * Copyright (c) NVIDIA CORPORATION & AFFILIATES, 2025. ALL RIGHTS RESERVED.
2+ * Copyright (c) NVIDIA CORPORATION & AFFILIATES, 2025-2026 . ALL RIGHTS RESERVED.
33 *
44 * See file LICENSE for terms.
55 */
1010
1111#include "gdaki.h"
1212
13+ #include <ucs/sys/sock.h>
1314#include <ucs/time/time.h>
1415#include <ucs/datastruct/string_buffer.h>
1516#include <ucs/algorithm/qsort_r.h>
@@ -142,6 +143,7 @@ static int uct_gdaki_check_umem_dmabuf(const uct_ib_md_t *md)
142143
143144 mlx5dv_devx_umem_dereg (umem );
144145out_free :
146+ ucs_close_fd (& dmabuf .fd );
145147 cuMemFree (buff );
146148out_ctx_pop :
147149 UCT_CUDADRV_FUNC_LOG_WARN (cuCtxPopCurrent (NULL ));
@@ -202,6 +204,7 @@ uct_rc_gdaki_umem_reg(const uct_ib_md_t *md, struct ibv_context *ibv_context,
202204 void * address , size_t length , uint64_t pgsz_bitmap )
203205{
204206 struct mlx5dv_devx_umem_in umem_in = {};
207+ struct mlx5dv_devx_umem * umem ;
205208 uct_cuda_copy_md_dmabuf_t dmabuf UCS_V_UNUSED ;
206209
207210 umem_in .addr = address ;
@@ -216,7 +219,11 @@ uct_rc_gdaki_umem_reg(const uct_ib_md_t *md, struct ibv_context *ibv_context,
216219 }
217220#endif
218221
219- return mlx5dv_devx_umem_reg_ex (ibv_context , & umem_in );
222+ umem = mlx5dv_devx_umem_reg_ex (ibv_context , & umem_in );
223+ #if HAVE_DECL_MLX5DV_UMEM_MASK_DMABUF
224+ ucs_close_fd (& dmabuf .fd );
225+ #endif
226+ return umem ;
220227}
221228
222229static UCS_CLASS_INIT_FUNC (uct_rc_gdaki_ep_t , const uct_ep_params_t * params )
@@ -712,6 +719,7 @@ static ucs_status_t uct_rc_gdaki_reg_mr(const uct_ib_md_t *md, void *address,
712719{
713720 uct_md_mem_reg_params_t params ;
714721 uct_cuda_copy_md_dmabuf_t dmabuf ;
722+ ucs_status_t status ;
715723
716724 params .field_mask = UCT_MD_MEM_REG_FIELD_FLAGS |
717725 UCT_MD_MEM_REG_FIELD_DMABUF_FD |
@@ -721,8 +729,10 @@ static ucs_status_t uct_rc_gdaki_reg_mr(const uct_ib_md_t *md, void *address,
721729 params .dmabuf_fd = dmabuf .fd ;
722730 params .dmabuf_offset = dmabuf .offset ;
723731
724- return uct_ib_reg_mr (md , address , length , & params , UCT_IB_MEM_ACCESS_FLAGS ,
725- NULL , mr_p );
732+ status = uct_ib_reg_mr (md , address , length , & params ,
733+ UCT_IB_MEM_ACCESS_FLAGS , NULL , mr_p );
734+ ucs_close_fd (& dmabuf .fd );
735+ return status ;
726736}
727737
728738static UCS_CLASS_INIT_FUNC (uct_rc_gdaki_iface_t , uct_md_h tl_md ,
@@ -1169,4 +1179,4 @@ UCT_TL_DEFINE_ENTRY(&uct_ib_component, rc_gda, uct_gdaki_query_tl_devices,
11691179 uct_rc_gdaki_iface_config_table ,
11701180 uct_rc_gdaki_iface_config_t );
11711181
1172- UCT_TL_INIT (& uct_ib_component , rc_gda , ctor , , )
1182+ UCT_TL_INIT (& uct_ib_component , rc_gda , ctor , , )
0 commit comments