Skip to content

wdc-nvme: validate PCI ID lookup in wdc_log_page_directory()#3522

Merged
igaw merged 1 commit into
linux-nvme:masterfrom
sahmed-ibm:fix-wdc-nvme-uninitialized-value-deviceid
Jun 30, 2026
Merged

wdc-nvme: validate PCI ID lookup in wdc_log_page_directory()#3522
igaw merged 1 commit into
linux-nvme:masterfrom
sahmed-ibm:fix-wdc-nvme-uninitialized-value-deviceid

Conversation

@sahmed-ibm

Copy link
Copy Markdown
Contributor

wdc_get_pci_ids() returns an error if it fails to retieve the PCI device ID. In that case, device_id remains uninitialized, and using it later in wdc_log_page_directory() results in undefined behavior.

Check the return value from wdc_get_pci_ids() and bail out early if the PCI ID lookup fails.

This issue was reported by the clang static analyzer.

Signed-off-by: Sarah Ahmed sarah.ahmed@ibm.com

Comment thread plugins/wdc/wdc-nvme.c Outdated
@@ -10867,6 +10864,9 @@ static int wdc_log_page_directory(int argc, char **argv, struct command *acmd,


ret = wdc_get_pci_ids(ctx, hdl, &device_id, &read_vendor_id);
if (ret) {
return ret;
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

drop the brackets to follow the coding style in this file (see a few lines above for example). thanks!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will do!

wdc_get_pci_ids() returns an error if it fails to retieve the PCI device
ID. In that case, device_id remains uninitialized, and using it later in
wdc_log_page_directory() results in undefined behavior.

Check the return value from wdc_get_pci_ids() and bail out early if the
PCI ID lookup fails.

This issue was reported by the clang static analyzer.

Signed-off-by: Sarah Ahmed <sarah.ahmed@ibm.com>
@sahmed-ibm sahmed-ibm force-pushed the fix-wdc-nvme-uninitialized-value-deviceid branch from 0192ed2 to 3886a90 Compare June 29, 2026 20:37
@sahmed-ibm

Copy link
Copy Markdown
Contributor Author

Dropped the braces around the single-statement if to match the surrounding coding style

@igaw igaw merged commit 94e4499 into linux-nvme:master Jun 30, 2026
31 of 32 checks passed
@igaw

igaw commented Jun 30, 2026

Copy link
Copy Markdown
Collaborator

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants