Skip to content

Commit c7b67e0

Browse files
committed
tree: avoid segfault if subsysnqn is not available
A nvme config command specifying the -M & -J options would end up in a segfault if subsysnqn is NULL, as shown below: nvme config -M -J /etc/nvme/config.json Segmentation fault (core dumped) Avoid this segfault by proceeding with the subsysnqn strcmp in nvme_lookup_subsystem() only if subsysnqn is available. Signed-off-by: Martin George <[email protected]>
1 parent 904b3a3 commit c7b67e0

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

src/nvme/tree.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,8 @@ struct nvme_subsystem *nvme_lookup_subsystem(struct nvme_host *h,
414414
struct nvme_subsystem *s;
415415

416416
nvme_for_each_subsystem(h, s) {
417-
if (strcmp(s->subsysnqn, subsysnqn))
417+
if (subsysnqn && s->subsysnqn &&
418+
strcmp(s->subsysnqn, subsysnqn))
418419
continue;
419420
if (name && s->name &&
420421
strcmp(s->name, name))

0 commit comments

Comments
 (0)