From c9cd7243edcb3ab437e80842a8492db386f126bc Mon Sep 17 00:00:00 2001 From: John Bachan Date: Mon, 3 Oct 2022 17:02:15 -0700 Subject: [PATCH] Fixes a double-free in the error path of ncclCommInitAll. Fixes https://github.com/NVIDIA/nccl/issues/726 [ROCm/rccl commit: 2401f4a91855b2ac78c5bad3e6657913b7124121] --- projects/rccl/src/init.cc | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/projects/rccl/src/init.cc b/projects/rccl/src/init.cc index 42c1090178..8023c49b19 100644 --- a/projects/rccl/src/init.cc +++ b/projects/rccl/src/init.cc @@ -1215,6 +1215,7 @@ ncclResult_t ncclCommInitAll(ncclComm_t* comms, int ndev, const int* devlist) { gpuFlags[devlist[i]] = 1; } free(gpuFlags); + gpuFlags = nullptr; } ncclUniqueId uniqueId; @@ -1226,11 +1227,9 @@ ncclResult_t ncclCommInitAll(ncclComm_t* comms, int ndev, const int* devlist) { } NCCLCHECKGOTO(ncclGroupEnd(), ret, fail); -exit: - return ret; fail: - if (gpuFlags) free(gpuFlags); - goto exit; + free(gpuFlags); + return ret; } ncclResult_t ncclCommSetAsyncError(ncclComm_t comm, ncclResult_t nextState) {