Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tree: fix segfault in nvme_free_tree() #855

Merged
merged 1 commit into from
Jul 1, 2024

Conversation

martin-gpy
Copy link
Contributor

Commands like nvme list & list-subsys currently segfault for --help or any invalid command option as shown below:

nvme list -h
Usage: nvme list [OPTIONS]

Retrieve basic information for all NVMe namespaces

Options:
[ --verbose, -v ] --- output verbosity
[ --output-format=, -o ] --- format: normal|json|binary
Segmentation fault (core dumped)

This is due to an invalid dereferencing of the nvme_root_t object in nvme_free_tree(). Fix this by checking whether this object is valid before dereferencing and freeing it. And while we are it, ensure r->options is also valid before freeing it.

Commands like nvme list & list-subsys currently segfault for --help or
any invalid command option as shown below:

nvme list -h
Usage: nvme list <device> [OPTIONS]

Retrieve basic information for all NVMe namespaces

Options:
  [  --verbose, -v ]                    --- output verbosity
  [  --output-format=<FMT>, -o <FMT> ]  --- format: normal|json|binary
Segmentation fault (core dumped)

This is due to an invalid dereferencing of the nvme_root_t object in
nvme_free_tree(). Fix this by checking whether this object is valid
before dereferencing and freeing it. And while we are it, ensure
r->options is also valid before freeing it.

Signed-off-by: Martin George <marting@netapp.com>
@igaw igaw merged commit 5bb5c8f into linux-nvme:master Jul 1, 2024
14 checks passed
@igaw
Copy link
Collaborator

igaw commented Jul 1, 2024

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