Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/nvme/private.h
Original file line number Diff line number Diff line change
Expand Up @@ -335,4 +335,11 @@ void __nvme_mi_mctp_set_ops(const struct __mi_mctp_socket_ops *newops);
int __nvme_import_keys_from_config(nvme_host_t h, nvme_ctrl_t c,
long *keyring_id, long *key_id);

static inline char *xstrdup(const char *s)
{
if (!s)
return NULL;
return strdup(s);
}

#endif /* _LIBNVME_PRIVATE_H */
6 changes: 3 additions & 3 deletions src/nvme/tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -2073,8 +2073,8 @@ static int nvme_reconfigure_ctrl(nvme_root_t r, nvme_ctrl_t c, const char *path,
}
closedir(d);

c->name = strdup(name);
c->sysfs_dir = strdup(path);
c->name = xstrdup(name);
c->sysfs_dir = xstrdup(path);
c->firmware = nvme_get_ctrl_attr(c, "firmware_rev");
c->model = nvme_get_ctrl_attr(c, "model");
c->state = nvme_get_ctrl_attr(c, "state");
Expand Down Expand Up @@ -2230,7 +2230,7 @@ static nvme_ctrl_t nvme_ctrl_alloc(nvme_root_t r, nvme_subsystem_t s,
return NULL;
}
FREE_CTRL_ATTR(c->address);
c->address = strdup(addr);
c->address = xstrdup(addr);
if (s->subsystype && !strcmp(s->subsystype, "discovery"))
c->discovery_ctrl = true;
ret = nvme_reconfigure_ctrl(r, c, path, name);
Expand Down