Skip to content

Commit fe89efa

Browse files
committed
tree: do not set dhchap_key to 'none'
When no dhchap key is set the kernel will set the sysfs attribute to 'none'. And we shouldn't display this value in our internal tree as it really means 'not set'. Signed-off-by: Hannes Reinecke <[email protected]>
1 parent 3dfc585 commit fe89efa

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

src/nvme/tree.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -505,6 +505,10 @@ static int nvme_scan_subsystem(struct nvme_root *r, const char *name,
505505
if (h->dhchap_key)
506506
free(h->dhchap_key);
507507
h->dhchap_key = nvme_get_attr(path, "dhchap_secret");
508+
if (h->dhchap_key && !strcmp(h->dhchap_key, "none")) {
509+
free(h->dhchap_key);
510+
h->dhchap_key = NULL;
511+
}
508512
}
509513
}
510514
if (!h)
@@ -1106,6 +1110,10 @@ static int nvme_configure_ctrl(nvme_root_t r, nvme_ctrl_t c, const char *path,
11061110
c->serial = nvme_get_ctrl_attr(c, "serial");
11071111
c->sqsize = nvme_get_ctrl_attr(c, "sqsize");
11081112
c->dhchap_key = nvme_get_ctrl_attr(c, "dhchap_ctrl_secret");
1113+
if (c->dhchap_key && !strcmp(c->dhchap_key, "none")) {
1114+
free(c->dhchap_key);
1115+
c->dhchap_key = NULL;
1116+
}
11091117
return 0;
11101118
}
11111119

@@ -1306,6 +1314,10 @@ nvme_ctrl_t nvme_scan_ctrl(nvme_root_t r, const char *name)
13061314
if (h->dhchap_key)
13071315
free(h->dhchap_key);
13081316
h->dhchap_key = nvme_get_attr(path, "dhchap_secret");
1317+
if (h->dhchap_key && !strcmp(h->dhchap_key, "none")) {
1318+
free(h->dhchap_key);
1319+
h->dhchap_key = NULL;
1320+
}
13091321
}
13101322
if (!h) {
13111323
h = nvme_default_host(r);

0 commit comments

Comments
 (0)