From b74c00f548affd0cf8188fddbbb315173764bf1f Mon Sep 17 00:00:00 2001 From: Wenkai Du Date: Fri, 9 Aug 2019 10:22:14 -0700 Subject: [PATCH] Fix memory leak and possible buffer overrun [ROCm/rccl-tests commit: ab82f1af6f5a373bb71fe0c44b8d772db24a03af] --- projects/rccl-tests/src/common.cu | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/projects/rccl-tests/src/common.cu b/projects/rccl-tests/src/common.cu index 4f97a4847f..36f2aa0941 100644 --- a/projects/rccl-tests/src/common.cu +++ b/projects/rccl-tests/src/common.cu @@ -398,6 +398,7 @@ testResult_t testStreamSynchronize(int ngpus, hipStream_t* streams, ncclComm_t* // We might want to let other threads (including NCCL threads) use the CPU. if (idle) pthread_yield(); } + free(done); return testSuccess; } @@ -814,7 +815,7 @@ testResult_t run() { int rank = proc*nThreads*nGpus+i; hipDeviceProp_t prop; HIPCHECK(hipGetDeviceProperties(&prop, hipDev)); - len += snprintf(line+len, MAX_LINE-len, "# Rank %2d Pid %6d on %10s device %2d [0x%02x] %s\n", + len += snprintf(line+len, MAX_LINE>len ? MAX_LINE-len : 0, "# Rank %2d Pid %6d on %10s device %2d [0x%02x] %s\n", rank, getpid(), hostname, hipDev, prop.pciBusID, prop.name); }