From 06292cfc6a5ecfc64a24290fe1ae70fe2d7bf936 Mon Sep 17 00:00:00 2001 From: Jatin Chaudhary Date: Wed, 15 Nov 2023 13:27:15 +0000 Subject: [PATCH] SWDEV-431399 - fix issues highlighted by address sanitizer Change-Id: I927009a8d408bdf13677ce5cc926908fb4552441 [ROCm/hip-tests commit: a87786f060b1770141637b782460ab8270c06edc] --- .../hip-tests/catch/unit/device/hipDeviceGetPCIBusId.cc | 2 +- .../catch/unit/device/hipDeviceSetGetCacheConfig.cc | 4 ++-- .../hip-tests/catch/unit/device/hipGetDeviceAttribute.cc | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/projects/hip-tests/catch/unit/device/hipDeviceGetPCIBusId.cc b/projects/hip-tests/catch/unit/device/hipDeviceGetPCIBusId.cc index 2ae3774395..90f34f6653 100644 --- a/projects/hip-tests/catch/unit/device/hipDeviceGetPCIBusId.cc +++ b/projects/hip-tests/catch/unit/device/hipDeviceGetPCIBusId.cc @@ -84,7 +84,7 @@ TEST_CASE("Unit_hipDeviceGetPCIBusId_Check_PciBusID_WithAttr") { } // Deallocate for (int i = 0; i < deviceCount; i++) { - delete hipDeviceList[i]; + delete[] hipDeviceList[i]; } delete[] hipDeviceList; printf("pciBusID output of both hipDeviceGetPCIBusId and" diff --git a/projects/hip-tests/catch/unit/device/hipDeviceSetGetCacheConfig.cc b/projects/hip-tests/catch/unit/device/hipDeviceSetGetCacheConfig.cc index 5034bf9d46..fa3e8b885e 100644 --- a/projects/hip-tests/catch/unit/device/hipDeviceSetGetCacheConfig.cc +++ b/projects/hip-tests/catch/unit/device/hipDeviceSetGetCacheConfig.cc @@ -167,8 +167,8 @@ TEST_CASE("Unit_hipDeviceGetCacheConfig_Positive_Threaded") { void TestPart3() { hipFuncCache_t returned_cache_config; - HIP_CHECK(hipDeviceGetCacheConfig(&returned_cache_config)); - REQUIRE(returned_cache_config == cache_config_); + HIP_CHECK_THREAD(hipDeviceGetCacheConfig(&returned_cache_config)); + REQUIRE_THREAD(returned_cache_config == cache_config_); } private: diff --git a/projects/hip-tests/catch/unit/device/hipGetDeviceAttribute.cc b/projects/hip-tests/catch/unit/device/hipGetDeviceAttribute.cc index 4316ec86f4..4731619072 100644 --- a/projects/hip-tests/catch/unit/device/hipGetDeviceAttribute.cc +++ b/projects/hip-tests/catch/unit/device/hipGetDeviceAttribute.cc @@ -328,14 +328,14 @@ TEST_CASE("Unit_hipGetDeviceAttribute_CheckFineGrainSupport") { char command_op[BUFFER_LEN]; int count = -1; // Extract each segment flags - while (fgets(command_op, BUFFER_LEN, fpipe)) { + while (fgets(command_op, BUFFER_LEN, fpipe) && (count + 1) < deviceCount) { std::string rocminfo_line(command_op); if ((std::string::npos != rocminfo_line.find("GPU-")) && (std::string::npos != rocminfo_line.find("Uuid:"))) { count++; gpuFound[count] = true; - } else if (gpuFound[count] && - (std::string::npos != rocminfo_line.find("FLAGS: FINE GRAINED"))) { + } else if (count >= 0 && gpuFound[count] && + (std::string::npos != rocminfo_line.find("FLAGS: FINE GRAINED"))) { fine_grained_val[count] = 1; } }