From e3845eaddf11fc36e8c94ffa7971840c45758410 Mon Sep 17 00:00:00 2001 From: Laraib Javed Date: Mon, 13 Jul 2026 13:30:18 -0500 Subject: [PATCH] wdc: fix null pointer dereference in get_dev_mgmt_log_page_lid_data() The get_dev_mgmt_log_page_lid_data() function initializes @sph to a pointer derived from @data before passing it to wdc_get_dev_mng_log_entry(). However, that function immediately sets *p_p_found_log_entry to NULL, making the initial value of @sph irrelevant and leaving a potentially misleading non-NULL value before the call. The Clang static analyzer flags this as a null pointer dereference since @sph may be NULL when dereferenced after the function call. Initialize @sph to NULL before the call to make the intent clear and suppress the false dereference warning. Signed-off-by: Laraib Javed --- plugins/wdc/wdc-nvme.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/plugins/wdc/wdc-nvme.c b/plugins/wdc/wdc-nvme.c index ac7ce05570..876823485e 100644 --- a/plugins/wdc/wdc-nvme.c +++ b/plugins/wdc/wdc-nvme.c @@ -2460,11 +2460,6 @@ bool wdc_get_dev_mng_log_entry(__u32 log_length, __u32 entry_id, __u32 offset = 0; struct wdc_c2_log_subpage_header *p_next_log_entry = NULL; - if (!*p_p_found_log_entry) { - fprintf(stderr, "ERROR: WDC - %s: No ppLogEntry pointer.\n", __func__); - return false; - } - *p_p_found_log_entry = NULL; /* Ensure log data is large enough for common header */ @@ -2693,7 +2688,7 @@ static bool get_dev_mgmt_log_page_lid_data(struct libnvme_transport_handle *hdl, /* Check the log data to see if the WD version of log page ID's is found */ length = sizeof(struct wdc_c2_log_page_header); hdr_ptr = (struct wdc_c2_log_page_header *)data; - sph = (struct wdc_c2_log_subpage_header *)(data + length); + sph = NULL; found = wdc_get_dev_mng_log_entry(le32_to_cpu(hdr_ptr->length), log_id, hdr_ptr, &sph); if (found && sph) { *cbs_data = calloc(le32_to_cpu(sph->length), sizeof(__u8));