Skip to content

Commit 9081645

Browse files
committed
tree: Avoid dereferencing nvme_subsystem_t before its check for NULL
1 parent 031132a commit 9081645

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
@@ -1023,11 +1023,12 @@ nvme_ctrl_t nvme_lookup_ctrl(nvme_subsystem_t s, const char *transport,
10231023
const char *host_iface, const char *trsvcid,
10241024
nvme_ctrl_t p)
10251025
{
1026-
nvme_root_t r = s->h ? s->h->r : NULL;
1026+
nvme_root_t r;
10271027
struct nvme_ctrl *c;
10281028

10291029
if (!s || !transport)
10301030
return NULL;
1031+
r = s->h ? s->h->r : NULL;
10311032
c = p ? nvme_subsystem_next_ctrl(s, p) : nvme_subsystem_first_ctrl(s);
10321033
for (; c != NULL; c = nvme_subsystem_next_ctrl(s, c)) {
10331034
if (strcmp(c->transport, transport))

0 commit comments

Comments
 (0)