Skip to content

tree-fabrics: fix null pointer dereference in ctrl_lookups() - #3779

Open
sahmed-ibm wants to merge 1 commit into
linux-nvme:masterfrom
sahmed-ibm:fix-tree-fabrics-null-returns
Open

tree-fabrics: fix null pointer dereference in ctrl_lookups()#3779
sahmed-ibm wants to merge 1 commit into
linux-nvme:masterfrom
sahmed-ibm:fix-tree-fabrics-null-returns

Conversation

@sahmed-ibm

Copy link
Copy Markdown
Contributor

The ctrl_lookups() function calls libnvme_first_host() to get the first host entry, then immediately passes h to
libnvme_get_subsystem() without checking whether the return value is NULL.

libnvme_first_host() returns NULL when the host list is empty. Dereferencing a NULL h inside libnvme_get_subsystem() causes undefined behavior.

Add shr_assert(h) after the call to libnvme_first_host() to catch a NULL return and abort early, consistent with the existing check used after libnvme_create_host() in the same file.

The ctrl_lookups() function calls libnvme_first_host() to get the
first host entry, then immediately passes @h to
libnvme_get_subsystem() without checking whether the return value
is NULL.

libnvme_first_host() returns NULL when the host list is empty.
Dereferencing a NULL @h inside libnvme_get_subsystem() causes
undefined behavior.

Add shr_assert(h) after the call to libnvme_first_host() to catch
a NULL return and abort early, consistent with the existing check
used after libnvme_create_host() in the same file.

Signed-off-by: Sarah Ahmed <sarah.ahmed@ibm.com>
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.

1 participant