From a83ee69dd36479e5fb99cb8c8b7c5bf9dd4228c8 Mon Sep 17 00:00:00 2001 From: Divya Shikre Date: Wed, 1 Dec 2021 11:43:50 -0500 Subject: [PATCH] Add null ptr check for temperature read from all sensors. The (temperature == nullptr) check happens only when HBM temperature is retrieved. This check needs to apply in other cases as well, hence moving this outside the HBM condition. This should return RSMI_STATUS_INVALID_ARGS consistently in all cases when nullptr is passed through rsmitst. Signed-off-by: Divya Shikre Change-Id: Iea3cec75312a0a669c7da27e15e9782e6a885c5f [ROCm/rocm_smi_lib commit: 432df203212bae06a8c33048cf11ff6deaae505d] --- projects/rocm-smi-lib/src/rocm_smi.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/projects/rocm-smi-lib/src/rocm_smi.cc b/projects/rocm-smi-lib/src/rocm_smi.cc index 8d49b3702c..d698c813ef 100755 --- a/projects/rocm-smi-lib/src/rocm_smi.cc +++ b/projects/rocm-smi-lib/src/rocm_smi.cc @@ -2130,6 +2130,10 @@ rsmi_dev_temp_metric_get(uint32_t dv_ind, uint32_t sensor_type, mon_type = amd::smi::kMonInvalid; } + if (temperature == nullptr) { + return RSMI_STATUS_INVALID_ARGS; + } + // The HBM temperature is retreived from the gpu_metrics if (sensor_type == RSMI_TEMP_TYPE_HBM_0 || sensor_type == RSMI_TEMP_TYPE_HBM_1 @@ -2145,10 +2149,6 @@ rsmi_dev_temp_metric_get(uint32_t dv_ind, uint32_t sensor_type, return ret; } - if (temperature == nullptr) { - return RSMI_STATUS_INVALID_ARGS; - } - switch (sensor_type) { case RSMI_TEMP_TYPE_HBM_0: val_ui16 = gpu_metrics.temperature_hbm[0];