From 9ed4d6a9c707faf7347d9bb971243ed8ad84a697 Mon Sep 17 00:00:00 2001 From: Brandon Paupore Date: Tue, 24 Jun 2025 13:58:24 -0500 Subject: [PATCH] wdc: invalid customer ID fix The return value of this function represents what commands are supported by the target, so returning a -1 here incorrectly enables all capability checks. Instead, this updates the behavior to just log the error and continue to report the actual device capabilities. Reviewed-by: Jeffrey Lien Signed-off-by: Brandon Paupore --- plugins/wdc/wdc-nvme.c | 18 ++++++++++-------- plugins/wdc/wdc-nvme.h | 2 +- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/plugins/wdc/wdc-nvme.c b/plugins/wdc/wdc-nvme.c index a6c1572ecc..46070d023d 100644 --- a/plugins/wdc/wdc-nvme.c +++ b/plugins/wdc/wdc-nvme.c @@ -1784,10 +1784,11 @@ static __u64 wdc_get_drive_capabilities(nvme_root_t r, struct nvme_dev *dev) capabilities |= WDC_DRIVE_CAP_D0_LOG_PAGE; cust_id = wdc_get_fw_cust_id(r, dev); - if (cust_id == WDC_INVALID_CUSTOMER_ID) { - fprintf(stderr, "%s: ERROR: WDC: invalid customer id\n", __func__); - return -1; - } + /* Can still determine some capabilities in this case, but log an error */ + if (cust_id == WDC_INVALID_CUSTOMER_ID) + fprintf(stderr, + "%s: ERROR: WDC: invalid customer ID; device ID = %x\n", + __func__, read_device_id); if ((cust_id == WDC_CUSTOMER_ID_0x1004) || (cust_id == WDC_CUSTOMER_ID_0x1008) || (cust_id == WDC_CUSTOMER_ID_0x1005) || (cust_id == WDC_CUSTOMER_ID_0x1304)) @@ -1866,10 +1867,11 @@ static __u64 wdc_get_drive_capabilities(nvme_root_t r, struct nvme_dev *dev) WDC_DRIVE_CAP_REASON_ID | WDC_DRIVE_CAP_LOG_PAGE_DIR); cust_id = wdc_get_fw_cust_id(r, dev); - if (cust_id == WDC_INVALID_CUSTOMER_ID) { - fprintf(stderr, "%s: ERROR: WDC: invalid customer id\n", __func__); - return -1; - } + /* Can still determine some capabilities in this case, but log an error */ + if (cust_id == WDC_INVALID_CUSTOMER_ID) + fprintf(stderr, + "%s: ERROR: WDC: invalid customer ID; device ID = %x\n", + __func__, read_device_id); if ((cust_id == WDC_CUSTOMER_ID_0x1004) || (cust_id == WDC_CUSTOMER_ID_0x1008) || diff --git a/plugins/wdc/wdc-nvme.h b/plugins/wdc/wdc-nvme.h index fa7a895cc8..525f05e0f9 100644 --- a/plugins/wdc/wdc-nvme.h +++ b/plugins/wdc/wdc-nvme.h @@ -5,7 +5,7 @@ #if !defined(WDC_NVME) || defined(CMD_HEADER_MULTI_READ) #define WDC_NVME -#define WDC_PLUGIN_VERSION "2.14.2" +#define WDC_PLUGIN_VERSION "2.14.3" #include "cmd.h" PLUGIN(NAME("wdc", "Western Digital vendor specific extensions", WDC_PLUGIN_VERSION),