Skip to content

Commit

Permalink
prov/efa: fix leak of dmabuf fd in cuda p2p probe
Browse files Browse the repository at this point in the history
prior to this patch, when efa_hmem_info_check_p2p_support_cuda elected
to attempt dmabuf for p2p, we previously leaked the file descriptor
returned by cuMemGetHandleForAddressRange in all cases. This ultimately
meant the dmabuf stuck around for the lifetime of the process, even
after dereg and after releasing the memory back to the device mempool.

All calls to cuda_get_dmabuf_fd need a corresponding close call.

Signed-off-by: Nicholas Sielicki <[email protected]>
  • Loading branch information
aws-nslick authored and shijin-aws committed Jan 23, 2025
1 parent 2715617 commit 83ab8a3
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions prov/efa/src/efa_hmem.c
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ static inline void efa_hmem_info_check_p2p_support_cuda(struct efa_hmem_info *in
if (ret == FI_SUCCESS) {
ibv_mr = ibv_reg_dmabuf_mr(g_device_list[0].ibv_pd, dmabuf_offset,
len, (uint64_t)ptr, dmabuf_fd, ibv_access);
(void)close(dmabuf_fd);
if (!ibv_mr) {
EFA_INFO(FI_LOG_CORE,
"Unable to register CUDA device buffer via dmabuf: %s. "
Expand Down

0 comments on commit 83ab8a3

Please sign in to comment.