|
|
cce597 |
From 59e7477c5a18ec4bcb1f9b1e20d2303b4e0cafb1 Mon Sep 17 00:00:00 2001
|
|
|
cce597 |
From: Martin George <marting@netapp.com>
|
|
|
cce597 |
Date: Thu, 5 Aug 2021 18:01:24 +0530
|
|
|
cce597 |
Subject: [PATCH] nvme-print: fix 'nvme list' segfault if controller is
|
|
|
cce597 |
unavailable
|
|
|
cce597 |
|
|
|
cce597 |
Check if the controller is available before dereferencing the
|
|
|
cce597 |
controller attributes.
|
|
|
cce597 |
|
|
|
cce597 |
Signed-off-by: Martin George <marting@netapp.com>
|
|
|
cce597 |
---
|
|
|
cce597 |
nvme-print.c | 9 +++++++++
|
|
|
cce597 |
1 file changed, 9 insertions(+)
|
|
|
cce597 |
|
|
|
cce597 |
diff --git a/nvme-print.c b/nvme-print.c
|
|
|
cce597 |
index 8a2cbc4..0c0ec3b 100755
|
|
|
cce597 |
--- a/nvme-print.c
|
|
|
cce597 |
+++ b/nvme-print.c
|
|
|
cce597 |
@@ -6147,6 +6147,9 @@ static void nvme_show_list_item(struct nvme_namespace *n)
|
|
|
cce597 |
struct stat st;
|
|
|
cce597 |
int ret;
|
|
|
cce597 |
|
|
|
cce597 |
+ if (!n->ctrl)
|
|
|
cce597 |
+ return;
|
|
|
cce597 |
+
|
|
|
cce597 |
sprintf(path, "%s%s", n->ctrl->path, n->name);
|
|
|
cce597 |
ret = stat(path, &st);
|
|
|
cce597 |
if (ret < 0)
|
|
|
cce597 |
@@ -6203,6 +6206,9 @@ static void nvme_show_details_ns(struct nvme_namespace *n, bool ctrl)
|
|
|
cce597 |
char usage[128];
|
|
|
cce597 |
char format[128];
|
|
|
cce597 |
|
|
|
cce597 |
+ if (!n->ctrl)
|
|
|
cce597 |
+ return;
|
|
|
cce597 |
+
|
|
|
cce597 |
sprintf(usage,"%6.2f %2sB / %6.2f %2sB", nuse, u_suffix,
|
|
|
cce597 |
nsze, s_suffix);
|
|
|
cce597 |
sprintf(format,"%3.0f %2sB + %2d B", (double)lba, l_suffix,
|
|
|
cce597 |
@@ -6419,6 +6425,9 @@ static void json_simple_ns(struct nvme_namespace *n, struct json_object *devices
|
|
|
cce597 |
char *devnode;
|
|
|
cce597 |
struct stat st;
|
|
|
cce597 |
|
|
|
cce597 |
+ if (!n->ctrl)
|
|
|
cce597 |
+ return;
|
|
|
cce597 |
+
|
|
|
cce597 |
if (asprintf(&devnode, "%s%s", n->ctrl->path, n->name) < 0)
|
|
|
cce597 |
return;
|
|
|
cce597 |
|
|
|
cce597 |
--
|
|
|
cce597 |
2.27.0
|
|
|
cce597 |
|