wdc-nvme: validate PCI ID lookup in wdc_log_page_directory()#3522
Merged
igaw merged 1 commit intoJun 30, 2026
Merged
Conversation
igaw
reviewed
Jun 29, 2026
| @@ -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; | |||
| } | |||
Collaborator
There was a problem hiding this comment.
drop the brackets to follow the coding style in this file (see a few lines above for example). thanks!
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>
0192ed2 to
3886a90
Compare
Contributor
Author
|
Dropped the braces around the single-statement if to match the surrounding coding style |
Collaborator
|
Thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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