From ad3b7d9f0deb0f479bdb4381a4e311208139dfba Mon Sep 17 00:00:00 2001 From: "Bill(Shuzhou) Liu" Date: Tue, 7 Mar 2023 09:08:27 -0600 Subject: [PATCH] amdsmitst crash when read ECC counter If the amdsmi is fail to read ECC counter from sysfs file, it still assumes the data is read into vector, which causes crash. Add the check to make sure the data is read into the vector. Change-Id: Ia24331ee6e75408120248b0ed7bc58581a2f23ad --- rocm_smi/src/rocm_smi.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rocm_smi/src/rocm_smi.cc b/rocm_smi/src/rocm_smi.cc index a2824bfa24..0339bb4246 100755 --- a/rocm_smi/src/rocm_smi.cc +++ b/rocm_smi/src/rocm_smi.cc @@ -637,7 +637,7 @@ rsmi_dev_ecc_count_get(uint32_t dv_ind, rsmi_gpu_block_t block, ret = GetDevValueVec(type, dv_ind, &val_vec); - if (ret == RSMI_STATUS_FILE_ERROR) { + if (ret == RSMI_STATUS_FILE_ERROR || val_vec.size() != 2) { return RSMI_STATUS_NOT_SUPPORTED; } if (ret != RSMI_STATUS_SUCCESS) {