Skip to content

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

Merged
igaw merged 1 commit into
linux-nvme:masterfrom
sahmed-ibm:fix-tree-fabrics-null-returns
Aug 10, 2026
Merged

tree-fabrics: fix null pointer dereference in ctrl_lookups()#3779
igaw merged 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>
@igaw
igaw merged commit b945822 into linux-nvme:master Aug 10, 2026
33 checks passed
@igaw

igaw commented Aug 10, 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