]> www.infradead.org Git - users/sagi/nvme-cli.git/commitdiff
nvme-print: check namespace in nvme_ctrl_for_each_path()
authorHannes Reinecke <hare@suse.de>
Fri, 21 Jan 2022 07:17:34 +0000 (08:17 +0100)
committerHannes Reinecke <hare@suse.de>
Fri, 21 Jan 2022 07:17:34 +0000 (08:17 +0100)
We should check if the namespace is available when scanning all
paths in nvme_ctrl_for_each_path(); a controller might be resetting
and might not be able to access the namespaces here.

Signed-off-by: Hannes Reinecke <hare@suse.de>
nvme-print.c

index 894d25711ede52c55f72df7630eb46248d317b92..6c682fbe369cc256a519d179c4a86f5e8d6dc179 100644 (file)
@@ -6704,8 +6704,11 @@ static void nvme_show_detailed_list(nvme_root_t r)
                                }
 
                                nvme_ctrl_for_each_path(c, p) {
+                                       n = nvme_path_get_ns(p);
+                                       if (!n)
+                                               continue;
                                        printf("%s%s", first ? "": ", ",
-                                              nvme_ns_get_name(nvme_path_get_ns(p)));
+                                              nvme_ns_get_name(n));
                                        first = false;
                                }
                                printf("\n");