From e5d9e1361e71ff0c786fe43174e88f342429f1e1 Mon Sep 17 00:00:00 2001 From: "Mario Limonciello (AMD)" Date: Thu, 21 Aug 2025 23:05:07 -0500 Subject: [PATCH] Fix a crash when running `amd-smi version --cpu` When running on a system that doesn't support HSMP (such as an APU) then the following is observed: ``` /usr/include/c++/15.1.1/bits/stl_vector.h:1263: std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::operator[](size_type) [with _Tp = void*; _Alloc = std::allocator; reference = void*&; size_type = long unsigned int]: Assertion '__n < this->size()' failed. ``` This is because no "CPU" are detected on the SOC, which really means no CPUs that support HSMP. Catch this case so that a clean return can be passed up. Signed-off-by: Mario Limonciello (AMD) --- src/amd_smi/amd_smi.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/amd_smi/amd_smi.cc b/src/amd_smi/amd_smi.cc index d82894b6c7..dac6969bce 100644 --- a/src/amd_smi/amd_smi.cc +++ b/src/amd_smi/amd_smi.cc @@ -6309,6 +6309,8 @@ amdsmi_status_t amdsmi_get_cpu_handles(uint32_t *cpu_count, nullptr, &cpu_per_soc); if (status != AMDSMI_STATUS_SUCCESS) return status; + if (cpu_per_soc == 0) + continue; // Allocate the memory for the cpus std::vector plist(cpu_per_soc);