From 0b2253dca6a10d7faa1cf6f2716860bc47129d7f Mon Sep 17 00:00:00 2001 From: dpgilbert <dpgilbert@4ea69e1a-61f1-4043-bf83-b5c94c648137> Date: Sun, 30 Jan 2022 00:54:06 +0000 Subject: [PATCH] scsiprint.cpp: fix issue with Zoned block device statistics lpage specific to the WDC DC HC650 SAS ZBC disk git-svn-id: https://svn.code.sf.net/p/smartmontools/code/trunk@5306 4ea69e1a-61f1-4043-bf83-b5c94c648137 --- smartmontools/ChangeLog | 6 ++++++ smartmontools/scsiprint.cpp | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/smartmontools/ChangeLog b/smartmontools/ChangeLog index b04d48e96..4ded48f9b 100644 --- a/smartmontools/ChangeLog +++ b/smartmontools/ChangeLog @@ -1,5 +1,11 @@ $Id$ +2022-01-29 Douglas Gilbert <dgilbert@interlog.com> + + scsiprint.cpp: fix issue with Zoned block device + statistics lpage specific to the WDC DC HC650 + SAS ZBC disk. Visible with smartctl -x + 2022-01-28 Douglas Gilbert <dgilbert@interlog.com> scsicmds.cpp,scsiprint.cpp: the "Long (extended) diff --git a/smartmontools/scsiprint.cpp b/smartmontools/scsiprint.cpp index 221fdd89f..3f77f48a6 100644 --- a/smartmontools/scsiprint.cpp +++ b/smartmontools/scsiprint.cpp @@ -1468,6 +1468,7 @@ scsiPrintZBDeviceStats(scsi_device * device) static const char * hname = "Zoned block device statistics"; static const char * jname = "scsi_zoned_block_device_statistics"; + jout("%s:\n", hname); if ((err = scsiLogSense(device, DEVICE_STATS_LPAGE, ZB_DEV_STATS_L_SPAGE, gBuf, LOG_RESP_LONG_LEN, 0))) { print_on(); @@ -1499,6 +1500,9 @@ scsiPrintZBDeviceStats(scsi_device * device) int pc = sg_get_unaligned_be16(ucp + 0); // pcb = ucp[2]; int pl = ucp[3] + 4; + + if (pl < 12) + goto skip; /* DC HC650 has non-compliant 4 byte parameters */ switch (pc) { case 0: q = "Maximum open zones"; @@ -1575,6 +1579,7 @@ scsiPrintZBDeviceStats(scsi_device * device) default: /* ignore other parameter codes */ break; } +skip: num -= pl; ucp += pl; } -- GitLab