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
This commit is contained in:
Kent Russell
2022-06-16 10:58:00 -04:00
bovenliggende 4dd2398f3d
commit 6b6e840337
+4
Bestand weergeven
@@ -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: