]> www.infradead.org Git - users/sagi/nvme-cli.git/commitdiff
nvme: avoid segfault in show-topology
authorMartin George <marting@netapp.com>
Thu, 1 Aug 2024 19:02:27 +0000 (00:32 +0530)
committerDaniel Wagner <wagi@monom.org>
Fri, 2 Aug 2024 06:28:22 +0000 (08:28 +0200)
The show-topology command currently ends in a segfault for
ENOENT scenarios:

nvme show-topology
Failed to scan topology: No such file or directory
Segmentation fault (core dumped)

Fix this by eliminating the call to nvme_free_tree() since the
cleanup helper is already available here.

Signed-off-by: Martin George <marting@netapp.com>
nvme.c

diff --git a/nvme.c b/nvme.c
index 3c144698f41e36d0df0375415d24070a64025c06..20dfee648917d5230558948ad6cc52b6b25d65fb 100644 (file)
--- a/nvme.c
+++ b/nvme.c
@@ -9585,7 +9585,6 @@ static int show_topology_cmd(int argc, char **argv, struct command *command, str
        err = nvme_scan_topology(r, NULL, NULL);
        if (err < 0) {
                nvme_show_error("Failed to scan topology: %s", nvme_strerror(errno));
-               nvme_free_tree(r);
                return err;
        }