Skip to content

Commit 6e9b357

Browse files
committed
tree: Handle NULL hostid in nvme_lookup_host()
When hostid is specified for lookup and some of the tree host records carry a NULL, avoid a segfault here on strcmp().
1 parent e104b99 commit 6e9b357

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

src/nvme/tree.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -374,8 +374,8 @@ struct nvme_host *nvme_lookup_host(nvme_root_t r, const char *hostnqn,
374374
nvme_for_each_host(r, h) {
375375
if (strcmp(h->hostnqn, hostnqn))
376376
continue;
377-
if (hostid &&
378-
strcmp(h->hostid, hostid))
377+
if (hostid && (!h->hostid ||
378+
strcmp(h->hostid, hostid)))
379379
continue;
380380
return h;
381381
}

0 commit comments

Comments
 (0)