rocm_smi.py: Handle corrupted serial number

If the FRU has been corrupted, then the serial number will come in with
any manner of random bytes, which will cause decode() to fail
spectacularily. Check that the serial returned by the kernel is
alphanumeric, and print to the error log if not (then continue to the
next device).

Change-Id: If4f35b140b6089e02729b1490ed6b48d614a122a
Цей коміт міститься в:
Kent Russell committed 2022-06-16 17:29:08 -04:00
1 джерело 4dd2398f3d
коміт 6b6e840337
1 file changed
+4
+4
Переглянути файл
@@ -2161,6 +2161,10 @@ def showSerialNumber(deviceList):
for device in deviceList:
sn = create_string_buffer(256)
ret = rocmsmi.rsmi_dev_serial_number_get(device, sn, 256)
if not str(sn).isalnum():
printErrLog(device, "FRU Serial Number contains non-alphanumeric characters. FRU is likely corrupted")
continue
if rsmi_ret_ok(ret, device) and sn.value.decode():
printLog(device, 'Serial Number', sn.value.decode())
else: