From 3e7e4ab1ac735712063bc5ab345614e010c6b468 Mon Sep 17 00:00:00 2001 From: Bindhiya Kanangot Balakrishnan Date: Wed, 24 Sep 2025 14:57:45 -0500 Subject: [PATCH] [SWDEV-556005 & SWDEV-556853] Initialize temp-type map Added back the temp-type map initialization to RSMI_TEMP_TYPE_INVALID before probing hwmon files. This prevents std::out_of_range for unsupported or absent temperature sensor types. Signed-off-by: Bindhiya Kanangot Balakrishnan --- rocm_smi/src/rocm_smi_monitor.cc | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/rocm_smi/src/rocm_smi_monitor.cc b/rocm_smi/src/rocm_smi_monitor.cc index 866862d621..5d37b8a849 100644 --- a/rocm_smi/src/rocm_smi_monitor.cc +++ b/rocm_smi/src/rocm_smi_monitor.cc @@ -336,7 +336,11 @@ Monitor::setTempSensorLabelMap(void) { return 0; }; - for (uint32_t i = RSMI_TEMP_TYPE_FIRST; i <= RSMI_TEMP_TYPE_LAST; ++i) { + for (uint32_t t = RSMI_TEMP_TYPE_FIRST; t <= RSMI_TEMP_TYPE_LAST; ++t) { + temp_type_index_map_.insert( + {static_cast(t), RSMI_TEMP_TYPE_INVALID}); + } + for (uint32_t i = 1; i <= RSMI_TEMP_TYPE_LAST + 1; ++i) { if ((i <= RSMI_TEMP_TYPE_GENERAL_LAST) || (i >= RSMI_TEMP_TYPE_GPUBOARD_NODE_FIRST && i <= RSMI_TEMP_TYPE_GPUBOARD_NODE_LAST) || (i >= RSMI_TEMP_TYPE_GPUBOARD_VR_FIRST && i <= RSMI_TEMP_TYPE_GPUBOARD_LAST) || @@ -345,9 +349,6 @@ Monitor::setTempSensorLabelMap(void) { if (ret) { return ret; } - } else { - temp_type_index_map_.insert( - {static_cast(i), RSMI_TEMP_TYPE_INVALID}); } } return 0;