]> www.infradead.org Git - users/sagi/libnvme.git/commitdiff
tree: avoid crash on unset subsystem in nvme_ctrl_get_host{nqn,id}
authorHannes Reinecke <hare@suse.de>
Thu, 12 Aug 2021 09:28:31 +0000 (11:28 +0200)
committerHannes Reinecke <hare@suse.de>
Thu, 12 Aug 2021 09:28:31 +0000 (11:28 +0200)
Signed-off-by: Hannes Reinecke <hare@suse.de>
src/nvme/tree.c

index 2c8192fd07df76143ec9e561c0f6c9ba9dbcda4e..6bcaf035eccb82361b9373791c04ec7ff091b9a8 100644 (file)
@@ -652,14 +652,14 @@ const char *nvme_ctrl_get_host_iface(nvme_ctrl_t c)
 
 const char *nvme_ctrl_get_hostnqn(nvme_ctrl_t c)
 {
-       if (!c->s)
+       if (!c->s || !c->s->h)
                return default_host->hostnqn;
        return c->s->h->hostnqn;
 }
 
 const char *nvme_ctrl_get_hostid(nvme_ctrl_t c)
 {
-       if (!c->s)
+       if (!c->s || !c->s->h)
                return default_host->hostid;
        return c->s->h->hostid;
 }